• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending E-mails Using the JavaMail (How to Do It?)

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using the Windows XP.

I have tried exercises at http://developer.java.sun.com/developer/onlineTraining/JavaMail/exercises/MailSetup/help.html

Now, I am building a web site. I provide visitors of the web site with a form to send e-mails. The form has text fields: To, From, Subject and a text area for users to type the body of the e-mail message. I would like to use the JavaMail when users click on the 'Send" button.

How do I do it using the JavaMail?
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Have you looked at the API docs and followed the tutorial?

http://java.sun.com/products/javamail/1.2/docs/javadocs/
http://java.sun.com/developer/onlineTraining/JavaMail/contents.html

have you written any code yet? I would implement this as a servlet, passing the form fields to it via the doPost() method. Perhaps if you make a start we can help out with specific questions.

My colleague recently wrote an email servlet to use in our web-apps...I don't think the manager could quite believe it when we told him it could be used to send email from any address, to any address. We sent him an email from himself to himself just to prove it
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have seen the tutorial at the http://java.sun.com/developer/onlineTraining/JavaMail/contents.html

I have an MS Outlook e-mail account. I also have a Yahoo e-mail account. In order to send e-mail messages from my Outlook account to my Yahoo e-mail account, I think that I need a SMTP server. Where is the SMTP server?

I am using the Windows XP. And I have the MS Outlook in my machine.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Where is the SMTP server?


That's not a question any of us can answer. However you can find out for yourself - if you look in Outlook at the Services you have configured - there's probably one called "Microsoft Exchange Server". If you look at its properties, you should see a DNS name/IP for the SMTP server.
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that I am very confused.

I am developing an application right here in my machine. My application is about building a web site that allow users to fill out a mail message form (To: Subject: Message: ) and click on the 'send' button.

By just taking a look at the first SUN tutorial example. After we compile the msgsend.java, at the DOS prompt, we do:

C:\javamail-1_3_1-upd\javamail-1.3.1\demo>java msgsend -o from@address -M SMTP.Server to@address

it says that -M SMTP.server

1. What should we actually put after the '-M'. Is SMTP.server equivalent to IP address?

2. I think that my machine name is 131.167.241.117 because it is what I have found by typing

what is the role of my machine name playing in this whole thing?

3. if I use the Outlook SMTP (the Outlook is provided by the Organization that I am working at), I think that I have to find out the DNS name/IP and place it after '-M'. Is it correct?

4. I am able to see the Microsoft Exchange Server under the MS Outlook Tools --> Options --> Mail Setup --> Email Accounts. There is no 'properties' (I right-clicked my mouse at many places) for me to see. I only found something like: ws-bso-msel.milky-way.MyCompanyName.org
Does it look like it is the SMTP.server?

5. If I download a free source SMTP server, what is or how do I find the DNS name/IP for that server? (Am I asking the correct question?) Do I need a domain (aquire it somewhere)?

6. can the from@address be any address?
[ September 16, 2004: Message edited by: JiaPei Jen ]
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is SMTP.server equivalent to IP address?



not of your PC, no. You need the address of a real SMTP email server, that is the address of the mail server of your ISP, you will have to ask you ISP or your company network admin guys for this.

Once you have it working then yes you can send email from any address to any address.

ws-bso-msel.milky-way.MyCompanyName.org
Does it look like it is the SMTP.server?



could be...give it a try. Take a look at this code which I got from here.



where smtpServer = "ws-bso-msel.milky-way etc etc"....
[ September 17, 2004: Message edited by: Ben Wood ]
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I am able to see the Microsoft Exchange Server under the MS Outlook Tools --> Options --> Mail Setup --> Email Accounts. There is no 'properties' (I right-clicked my mouse at many places) for me to see. I only found something like: ws-bso-msel.milky-way.MyCompanyName.org
Does it look like it is the SMTP.server?


Try looking for the service under Tools>Services.... You should be able to see the service configured as you SMTP server there.
 
yeah, but ... what would PIE do? Especially concerning this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic