It's not a secret anymore!*
The moose likes Other JSE/JEE APIs and the fly likes Sending E-mails Using the JavaMail (How to Do It?) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Sending E-mails Using the JavaMail (How to Do It?)" Watch "Sending E-mails Using the JavaMail (How to Do It?)" New topic
Author

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

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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?
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
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


SCJP 1.4, www.gsi3d.org.uk
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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

Joined: Aug 14, 2001
Posts: 342
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

Joined: Apr 14, 2004
Posts: 10336


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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending E-mails Using the JavaMail (How to Do It?)