Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot send email through Outlook

 
Eduardo Ponce de Leon
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to send an email with javamail and I am not able to.

This is my code...



When I run this...this is my response



But when I try to add this lines to send a message




I get this error..



Can anybody help!!
 
Rob Spoor
Sheriff
Pie
Posts: 20532
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exception shows that it's trying to use "localhost" for sending. That's because, unlike the first piece of code, it uses the SMTP host specified in the Properties you use to get the Session. You probably didn't specify any, so it defaults to local host.

You can solve this two ways:
1) Specify the SMTP host with key "mail.smtp.host". The authentication must be done through keys "mail.smtp.user" and "mail.smtp.pass" or an Authenticator.
2) Get a Transport object as in your first piece of code, then first call saveChanges on the message and then use the Transport's non-static sendMessage method:

Also, you don't send emails through Outlook this way. Outlook is the client written by Microsoft. Their server software is called Exchange.
 
Eduardo Ponce de Leon
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,
Thank you for the reply. It was very helpful. Ive applied the changes you suggested and unfortunately something else came up, which I am not sure but might me harder to debug!

 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But that is specifically one of the entries in the JavaMail FAQ. I strongly recommend you read this document -- not just the part about your current problem, but all of it. That should give you a better insight into how Internet e-mail works.
 
Eduardo Ponce de Leon
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
I cannot view the link.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then your google keywords are "javamail faq". If you can't read the link you get from your web search, then I suggest you go to your network manager and complain.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic