Share & Learn

Monday, June 04, 2007

"Must Specify STARTTLS Command First" error while using JavaMail API

Friends

I tried the JavaMail API (v1.4) , and let me tell you guys when you send the mail through browser you have to specify the SSL provider, and the older method of using the SSL provider class, does not work.

So guys here is the actual code that you should actually implement in your code:
The error that Java generally throws is "Must Specify STARTTLS Command first"

props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.socketFactory.port", SMTP_PORT);
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");

paste this code before using the Authenticator.

I had a torrid time, rectifying the error. So friends, here is that code snippet that could make your life a bit easier

Cheers

blog comments powered by Disqus
blog comments powered by Disqus