This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Java mail using gmail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java mail using gmail" Watch "Java mail using gmail" New topic

Java mail using gmail

blv krishna

Joined: Sep 27, 2009
Posts: 18
Hi All,

I wrote the following to send mail using java.

But i got the following ERROR.

SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first

Anyone please help me to reslove this error.

Steve Luke

Joined: Jan 28, 2003
Posts: 4167

Hi welcome to CodeRanch :-)

First, when you post code can you please use code tags? You can use the by putting [code][/code] tags around the code, or by using the Code button at the top of the message form. The code tags make it a lot easier to read your code. You can go ahead and add the code tags back into the message now using the button.

To your question. It looks like if you add the following line to your code, prior to sending the message, it works.

blv krishna

Joined: Sep 27, 2009
Posts: 18
Hi Steve,

After adding the below statement also i am getting the same error.

Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

Have you read the section about Gmail in the JavaMail FAQ yet?
I agree. Here's the link:
subject: Java mail using gmail
Similar Threads
Transport.send problem
use Linux sendmail from Java
Error - The trustAnchors parameter must be non-empty
how to mail send in servlets or jsp?
Java mail problem in IE