Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Email send failure

 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have got this exception while trying to run my application which suppose to send email message:

javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 Authentication require
d. Help at http://www.earthlink.net/go/emailsettings (failed to find host name f
rom IP address)

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
at javax.mail.Transport.send0(Transport.java:169)
at javax.mail.Transport.send(Transport.java:98)
at Reminder.sendMessage(Reminder.java:41)
at Reminder.main(Reminder.java:92)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 Authentication requ
ired. Help at http://www.earthlink.net/go/emailsettings (failed to find host nam
e from IP address)

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
... 5 more




my code is as follows:

[ April 03, 2007: Message edited by: A Yehia ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

550 Authentication required. Help at http://www.earthlink.net/go/emailsettings (failed to find host name from IP address)

This is your cause. You need authenticated to send mail.

Try the code below, instead of Transport.send()

[ April 03, 2007: Message edited by: Paul Sturrock ]
 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ve got this exception after reformating my code:

javax.mail.NoSuchProviderException: No provider for earthlink.net
at javax.mail.Session.getProvider(Session.java:455)
at javax.mail.Session.getTransport(Session.java:650)
at javax.mail.Session.getTransport(Session.java:631)
at Reminder.sendMessage(Reminder.java:42)
at Reminder.main(Reminder.java:99)


Code:

try {
String smtp = "earthlink.net";
Properties props = System.getProperties();
props.put("mail.smtp.host", smtp);
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom( new InternetAddress("me@hotmail.com"));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress("emailadress@hotmail.com"));
message.setSubject("Subject");
message.setText("Body Text");
Transport t = session.getTransport(smtp);
try {
t.connect("username", "password");
t.sendMessage(message, message.getAllRecipients());
} catch (Exception e) { }
finally {
t.close();
}
} catch (Exception e){
e.printStackTrace();
}
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you click on the link in your previous error message, http://www.earthlink.net/go/emailsettings, you get a page that tells you how to configure various email clients to use Earthlink SMTP, including the correct name for the SMTP server.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String smtp = "earthlink.net";
Properties props = System.getProperties();
props.put("mail.smtp.host", smtp);


You need to provide the mail server, which might be something like smtp.earthlink.net or mail.earthlink.net or some such. Consult the Earthlink documentation or online help to find what you need to put in there.
 
Sirish Kumar Gongal Reddy
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Before using your SMTP address try to ping that from command prompt if it's valid you will get reply from ping commnad.
CMD:>ping mail.yahoo.com

Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic