1.QQ Mailbox Settings
1.1 Go to QQ mailbox--set-up account--set up as
2.foxmail settings (because I want to use it to receive mail)
2.1 Refer to the official settings to http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=371
PS: Fill in the email password is a separate password: need to note that the SSL link to check; SMTP port is 465
Code configuration in 3.Java
3.1 Send mail configuration code
public class Mailutils {
public static void SendMail (string email, string emailmsg) throws Addressexception, messagingexception {//1. Create a program with Mail server Session Object sessions
Properties Props = new properties ();
Props.setproperty ("Mail.transport.protocol", "SMTP");
Props.setproperty ("Mail.host", "smtp.sohu.com");
Props.setproperty ("Mail.smtp.auth", "true");//Specify Authentication to True
Creating validators
Authenticator auth = new Authenticator () {
Public Passwordauthentication getpasswordauthentication () {
return new Passwordauthentication ("Hoobey", "1234567890");
}
};
Session session = Session.getinstance (props, auth);
2. Create a message that corresponds to the content of the message
Message message = new MimeMessage (session);
Message.setfrom (New InternetAddress ("[email protected]"); Set Sender
Message.setrecipient (recipienttype.to, new internetaddress (email)); Set the sending method and receiver
Message.setsubject ("User activation"); Message.settext ("This is an activation email, please <a href= ' # ' > Click </a>");
Message.setcontent (emailmsg, "text/html;charset=utf-8");
3. Create transport to send messages
Transport.send (message); } }
How to configure Java mail to send mail using QQ mailbox