This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman 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 Elasticsearch in Action this week in the Big Data 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: 4181

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: 19351

Have you read the section about Gmail in the JavaMail FAQ yet?
It is sorta covered in the JavaRanch Style Guide.
subject: Java mail using gmail