• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

JavaMail will not let me to authenticate myself

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I am able to authenticate myself to my ISP SMTP server through telnet and send (relay) emails to external domains.

HOWEVER for some obscure reason, I cannot do this through the JavaMail API. Could anyone let me know what is wrong with my code?

I appreciate your help.



While executing the code I am getting this error:




The code above does work if I try to send the email within smtp.my.isp.com (which does not require authentication), but it fails if I try to email it to some external SMTP server. Probably I am not getting authenticated with my ISP SMTP server. But Why???


[ July 20, 2007: Message edited by: Joseph Sweet ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just resolved a problem like yours, hope this is helpful.
As this doc:http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-summary.html
the smtp authentication is forbidden by default, if you mail server don't require an authentication, you app could connect the server without problem.
But if it need, you need declare it be true before create a connection.

Properties props = System.getProperties();

// -- Attaching to default Session, or we could start a new one --
// -- Could use Session.getTransport() and Transport.connect()
// , but assume we're using SMTP --

props.put("mail.smtp.host", smtpServer);
// add this line
props.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(props, null);
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic