GeeCON Prague 2014*
The moose likes Other JSE/JEE APIs and the fly likes Email send failure 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 "Email send failure" Watch "Email send failure" New topic
Author

Email send failure

ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424
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

Joined: Apr 14, 2004
Posts: 10336


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 ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424
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

Joined: Oct 29, 2001
Posts: 8915
    
    8

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
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.


Ping & DNS - my free Android networking tools app
Sirish Kumar Gongal Reddy
Ranch Hand

Joined: Oct 25, 2004
Posts: 109
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!
 
GeeCON Prague 2014
 
subject: Email send failure