Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
keerthana kuruba
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
keerthana kuruba
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot sir..... i have set the usename and password with this method PasswordAuthentication getPasswordAuthentication() in session.now it works fine...

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic