When your account was registered mail validation issues!
The class javax.mail. Mail. AuthenticationFailedException
The at javax.mail. Mail. Transport. Send0 (Transport. Java: 218)
The at javax.mail. Mail. Transport. Send (Transport. Java: 80)
The at MailUtils. MailUtils. SendAccountActivateEmail (MailUtils. Java: 47)
At the servlet. ListServlet_user. DoPost (ListServlet_user. Java: 193)
The at javax.mail. Servlet. HTTP. HttpServlet. Service (HttpServlet. Java: 647)
The at javax.mail. Servlet. HTTP. HttpServlet. Service (HttpServlet. Java: 728)
The at org. Apache. Catalina. Core. ApplicationFilterChain. InternalDoFilter (ApplicationFilterChain. Java: 305)
The at org. Apache. Catalina. Core. ApplicationFilterChain. DoFilter (ApplicationFilterChain. Java: 210)
The at org. Apache. Catalina. Core. StandardWrapperValve. Invoke (StandardWrapperValve. Java: 222)
The at org. Apache. Catalina. Core. StandardContextValve. Invoke (StandardContextValve. Java: 123)
The at org. Apache. Catalina. The authenticator. AuthenticatorBase. Invoke (AuthenticatorBase. Java: 472)
The at org. Apache. Catalina. Core. StandardHostValve. Invoke (StandardHostValve. Java: 171)
The at org. Apache. Catalina. Valves. ErrorReportValve. Invoke (ErrorReportValve. Java: 99)
The at org. Apache. Catalina. Valves. AccessLogValve. Invoke (AccessLogValve. Java: 953)
The at org. Apache. Catalina. Core. StandardEngineValve. Invoke (StandardEngineValve. Java: 118)
At org. Apache. Catalina. Connector. CoyoteAdapter. Service (408) CoyoteAdapter. Java:
The at org. Apache. Coyote. Http11. AbstractHttp11Processor. Process (AbstractHttp11Processor. Java: 1008)
The at org. Apache. Coyote. AbstractProtocol $AbstractConnectionHandler. Process (AbstractProtocol. Java: 589)
At org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run JIoEndpoint. Java: (310)
The at Java. Util. Concurrent. ThreadPoolExecutor. RunWorker (ThreadPoolExecutor. Java: 1145)
The at Java. Util. Concurrent. ThreadPoolExecutor $Worker. The run (ThreadPoolExecutor. Java: 615)
The at Java. Lang. Thread. The run (Thread. Java: 722)
The code
Package MailUtils;
import java.util.Date;
import java.util.Properties;
The import javax.mail. Mail. The Authenticator;
The import javax.mail. Mail. MessagingException;
The import javax.mail. Mail. PasswordAuthentication;
The import javax.mail. Mail. Session;
The import javax.mail. Mail. Transport;
The import javax.mail. Mail. Internet. InternetAddress;
The import javax.mail. Mail. Internet. MimeMessage;
The import javax.mail. Mail. Internet. MimeMessage. RecipientType;
The import tool. GenerateLinkUtils;
An import entity. The User;
Public class MailUtils {
Private static final String FROM="454 [email protected]";
Public static void sendAccountActivateEmail (User User) {
The Session Session=getSession ();
The MimeMessage message=new MimeMessage (session);
Try {
Message. SetSubject (" this is an activation email to the account ");
Message. SetSentDate (new Date ());
//setFrom said
with which email to send emailMessage. SetFrom (new InternetAddress (FROM));
/* *
* RecipientType TO | | BCC | | CC
* said TO main recipient
* BCC says secret cc people
* CC said CC person
* InternetAddress the recipient's email address
*/
Message. SetRecipient (RecipientType. TO new InternetAddress (user) getEmail ()));
Message. SetContent (" & lt; A target="_BLANK" href='" + GenerateLinkUtils. GenerateActivateLink (user) + "' & gt;" + user. GetUserName () + "hello Sir/madam, please click on this link to activate" + GenerateLinkUtils. GenerateActivateLink (user)
+ "& lt;/a>" , "text/HTML. charset=utf-8");
//message. SetContent (" & lt; A target="_BLANK" href='" + user. GetUserName () + "hello, Sir/madam, please click the link to activate" + GenerateLinkUtils. GenerateActivateLink (user) + "& lt;/a>" , "text/HTML. charset=utf-8");
Transport. Send (message);
} the catch (MessagingException e) {
e.printStackTrace();
}
}
Public static Session getSession () {
The Properties props=new Properties ();
Props. SetProperty (" mail, transport protocol ", "SMTP");
Props. SetProperty (" mail. Host ", "smtp.qq.com");
Props. SetProperty (" mail. The SMTP auth ", "true");//the specified to true
Props. The put (" mail. The SMTP. SSL. The enable ", "true");
The Session Session=Session. GetInstance (props, new Authenticator () {
@ Override
Protected PasswordAuthentication getPasswordAuthentication () {
Return new PasswordAuthentication (the FROM, "swghmvjbicmmcaih");
}
});
Return the session.
}
}