aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Getting SMTP transport error-Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Getting SMTP transport error-Exception in thread "main" com.sun.mail.smtp.SMTPSendFailedException: 5" Watch "Getting SMTP transport error-Exception in thread "main" com.sun.mail.smtp.SMTPSendFailedException: 5" New topic
Author

Getting SMTP transport error-Exception in thread "main" com.sun.mail.smtp.SMTPSendFailedException: 5

keerthana kuruba
Greenhorn

Joined: May 12, 2011
Posts: 22
I want to run a simple javamail program to send message to gmail using java program.but getting this error .kindly help me to solve this error and to execute this program properly.please let me know any changes is required in the program too.

here is the code..

output:
C:\Program Files\Java\jdk1.6.0_23\bin>javac MailExample.java

C:\Program Files\Java\jdk1.6.0_23\bin>java MailExample smtp.gmail.com keerth.kuruba@gmail.com keerthana.hari@gmail.com
Exception in thread "main" com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1
Authentication Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 lr4sm1384877
icb.20

at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1
829)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1368)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:886)
at javax.mail.Transport.send0(Transport.java:191)
at javax.mail.Transport.send(Transport.java:120)
at MailExample.main(MailExample.java:33)
Here while running this program i have valid gmailids for from and to address..still getting the same error.
In the above error,one error link is there and gone through this link..but didnt get any thing.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41905
    
  63
Did you notice that the error message states very precisely the reason for the error, and even provides a link to a more in-depth discussion of the problem?


Ping & DNS - my free Android networking tools app
keerthana kuruba
Greenhorn

Joined: May 12, 2011
Posts: 22
I have set mail.smtp.auth as true (props.put("mail.smtp.auth", "true"); ) then am getting some other error..as below


C:\Program Files\Java\jdk1.6.0_23\bin>javac MailExample.java

C:\Program Files\Java\jdk1.6.0_23\bin>java MailExample smtp.gmail.com keerth.kuruba@gmail.com keerthana.hari@gmail.com
Exception in thread "main" javax.mail.AuthenticationFailedException: failed to c
onnect, no password specified?
at javax.mail.Service.connect(Service.java:325)
at javax.mail.Service.connect(Service.java:172)
at javax.mail.Service.connect(Service.java:121)
at javax.mail.Transport.send0(Transport.java:190)
at javax.mail.Transport.send(Transport.java:120)
at MailExample.main(MailExample.java:34)

Here am sending samll message from one gmail id to another gmail id...then how to rectify this error
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41905
    
  63
How are you specifying username and password? Make sure you proceed according to http://www.oracle.com/technetwork/java/faq-135477.html#gmail

Once you are doing all of that, and it still doesn't work, post the code you have.
keerthana kuruba
Greenhorn

Joined: May 12, 2011
Posts: 22
Thanks a lot sir..... i have set the usename and password with this method PasswordAuthentication getPasswordAuthentication() in session.now it works fine...

 
wood burning stoves
 
subject: Getting SMTP transport error-Exception in thread "main" com.sun.mail.smtp.SMTPSendFailedException: 5