How to configure Java mail to send mail using QQ mailbox

Source: Internet
Author: User

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

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 ("", "");

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 (, 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.