|
DEBUG: setDebug: JavaMail version 1.3.1
DEBUG: getProvider () returning javax.mail.Provider [TRANSPORT, smtp, com.sun.mail.smtp.SMTPTransport, Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.163.com", port 25
220 163.com Anti-spam GT for Coremail System (163com [20050206])
DEBUG SMTP: connected to host "smtp.163.com", port: 25
EHLO nikodan
250-mail
250-PIPELINING
250-AUTH LOGIN PLAIN
250-AUTH = LOGIN PLAIN
250 8BITMIME
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN"
DEBUG SMTP: Found extension "AUTH = LOGIN", arg "PLAIN"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 dXNlcm5hbWU6
enh5b25nd2Vi
334 UGFzc3dvcmQ6
ODg4ODg4
550 users are locked
javax.mail.AuthenticationFailedException
-----------------------------------------
Source code:
import javax.mail. *;
import javax.mail.internet. *;
import javax.activation. *;
-------------------------
public boolean sendEmail (String to, String subject, String content) {
String host = "smtp.163.com"; // mail.thinkrev.com
String user = "zxyongweb";
String password = "zxyongdb";
String from = "zxyongweb@163.com";
Ranch
Properties props = new Properties ();
props.put ("mail.smtp.host", host); // Specify the SMTP server
props.put ("mail.smtp.auth", "true"); // Specify whether SMTP authentication is required
try
{
Session mailSession = Session.getDefaultInstance (props);
mailSession.setDebug (true); // Whether debug information is displayed in the console
Message message = new MimeMessage (mailSession);
message.setFrom (new InternetAddress (from)); // From
message.addRecipient (Message.RecipientType.TO, new InternetAddress (to)); // Recipient
message.setSubject (subject); // Mail subject
message.setText (content); // Email content
message.saveChanges ();
Transport transport = mailSession.getTransport ("smtp");
transport.connect (host, user, password);
log.error ("Start sending:");
transport.sendMessage (message, message.getAllRecipients ());
transport.close ();
} catch (Exception e)
{
log.error ("Email failed:" + e);
System.out.println (e);
return false;
}
log.error ("Started successfully:");
return true;
} |
|