public class MailSender {
Static final Logger Logger = Loggerfactory.getlogger (Mailsender.class);
Public MailSender () {
}
public static void SendMessage (string guest, String AccountName, String checkval) {
Properties props = System.getproperties ();
Props.put ("Mail.smtp.host", "smtp.163.com");
Props.put ("Mail.smtp.auth", "true");
Mailauthenticator Mailauth = new Mailauthenticator ("xmkj56@163.com", "glayshx"); //...
Session session = Session.getdefaultinstance (props, Mailauth);
try {
MimeMessage msg = new MimeMessage (session);
Msg.setfrom (New InternetAddress ("xmkj56@163.com", "Shanghai Auction Industry Association"));
Msg.addrecipient (Message.recipienttype.to,new internetaddress (guest));
Msg.setsubject ("Online auction" email user Registration verification ");
Msg.setsentdate (New Date ());
Msg.settext (AccountName + "\ n" +
"This letter was sent by the Shanghai Auction Industry Association. \ n "+
"\ n" +
"----------------------------------------------------------------------\ n" +
"Account activation instructions \ n" +
"----------------------------------------------------------------------\ n" +
"You are a new user of our website and we need to verify your address validity to avoid spam or address misuse." \ n "+
"You can activate your account by clicking on the link below: \ n" +
Constants.email_send_url + "/" + Checkval + "\ n" +
"http://wangpai1.staa.com.cn/" + checkval + "\ n" +
(If this is not a link, paste the address manually into the browser's address bar and then access it) \ n "+
"Thank you for your visit, I wish you a pleasant use." \ n "+
"\ n" +
"Yours \ n" +
"\ n" +
"Shanghai Auction Industry Association management team \ n" +
"http://wangpai.staa.com.cn\n");
Msg.savechanges (); Implicit with Send ()
transport.send (msg);
} catch (Messagingexception Mex) {
System.out.println ("Send failed, Exception:" + Mex);
} catch (Unsupportedencodingexception e) {
//TODO auto-generated Catch block
e.printstacktrace ();
}
}
public static void Sendpassmessage (string guest, String AccountName, String checkval) {
Properties props = System.getproperties ();
props.put ("Mail.smtp.host", "smtp.163.com");
props.put ("Mail.smtp.auth", "true");
mailauthenticator mailauth = new Mailauthenticator ("xmkj56@163.com", "glayshx"); /...
session Session = session.getdefaultinstance (props, Mailauth);
try {
MimeMessage msg = new MimeMessage (session);
Msg.setfrom (New InternetAddress ("xmkj56@163.com", "Shanghai Auction Industry Association"));
Msg.addrecipient (Message.recipienttype.to,new internetaddress (guest));
Msg.setsubject ("" Network Auction "email password back");
Msg.setsentdate (New Date ());
Msg.settext (AccountName + "\ n" +
"This letter was sent by the Shanghai Auction Industry Association. \ n "+
"\ n" +
"----------------------------------------------------------------------\ n" +
"Account password reset instructions \ n" +
"----------------------------------------------------------------------\ n" +
"You can do it at: \ n" +
Constants.email_send_url + "/" + "recoverpassmanage_email\n\n" +
"Use temporary password:" + checkval + "\n\n\n" +
"Thank you for your visit, I wish you a pleasant use." \ n "+
"\ n" +
"Yours \ n" +
"\ n" +
"Shanghai Auction Industry Association management team \ n" +
"http://wangpai.staa.com.cn\n");
Msg.savechanges (); Implicit with Send ()
Transport.send (msg);
} catch (Messagingexception Mex) {
System.out.println ("Send failed, Exception:" + Mex);
} catch (Unsupportedencodingexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
}
}