Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sending email from Java in Windows

843830Jan 14 2005 — edited Jul 25 2007
Just learning. All I have to do is to send a simple email to myself whenever my java application encounters some kind of misbehavior on client's site.

I made it thus:

import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;

public class MySendMail {

static void Send() {
try {
InternetAddress toAddress = new InternetAddress("my address","my name");
InternetAddress fromAddress = new InternetAddress("my adress", "my name");
Properties props = new Properties();
props.put("mail.smtp.host", "smtpauth.earthlink.net");
Session mailsession = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(mailsession);
msg.addRecipient(Message.RecipientType.TO, toAddress);
msg.setSubject("A Simple E-mail Message!");
msg.setFrom(fromAddress);
msg.setText("Sending this from java");
Transport.send(msg);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Executing MySendMail.Send() gets this exception:

javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class com.sun.mail.smtp.SMTPAddressFailedException: 550 Please configure your mail client to use authentication.

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1130)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:525)
at javax.mail.Transport.send0(Transport.java:151)
at javax.mail.Transport.send(Transport.java:80)
at MySendMail.Send(S3i2SendMail.java:19)

May anybody please tell me the reason for the exception.

Many thanks,
Alex
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 22 2007
Added on Jan 14 2005
10 comments
577 views