• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

cannot send email through Outlook

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

 
Sheriff
Posts: 28370
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul,
I cannot view the link.
 
Paul Clapham
Sheriff
Posts: 28370
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic