SMTP and JavaMail

grapepot

New Member
Messages
1
Reaction score
0
Points
0
Hey everyone,
I am trying to use my SMTP from x10 to send mail via JavaMail. I keep getting this error which means I can not connect to the SMTP.

"javax.mail.AuthenticationFailedException"

Any ideas why the SMTP isn't connecting. I am just trying to setup a simple program that will email people passwords when they forget theirs. I have tried with the SMTP Auth on (with login and password) and off with just the SMTP server name. They all give me the non access error.

Here is the important piece of the code... 'xxxx' are replaced with my actual login and password in the program.


Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.host", "mail.sflsl.x10hosting.com");
props.setProperty("mail.user", "xxxx");
props.setProperty("mail.password", "xxxx");

Session mailSession = Session.getDefaultInstance(props, null);
Transport transport = mailSession.getTransport("smtp");
MimeMessage message = new MimeMessage(mailSession);
message.setSubject(strTeamAbb + " Password!");
message.setContent(strTeamAbb + "password is " + strPassword, "text/plain");
message.setFrom(new InternetAddress(strEmail));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(strEmail));

transport.connect();
transport.send(message);
transport.close();
 
Top