Javaweb Online Book Mall complete project--Send mail

Source: Internet
Author: User

1, first register a 163 mailbox

Your e-mail address is [email protected]

The login password is [email protected]***19

e-mail, mail must turn on pop and SMTP service, log in mail

Open Pop service, this time prompted you must set the authorization password, I set here is wy87****

In the code must be set to this authorization password to send mail, cannot be set as a login password

The client needs the following two jar files

Let's look at the code for the program:

 Packagecom.weiyuan.test;Importjava.io.IOException;Importjavax.mail.MessagingException;Importjavax.mail.Session;Importorg.junit.Test;ImportCn.itcast.mail.Mail;Importcn.itcast.mail.MailUtils; Public classSendemailtest {/*need to use Mmail and Activation.jar **/@Test Public voidSendEmail ()throwsmessagingexception, ioexception{String host= "smtp.163.com";//QQ e-mail address, port 465 or 587//QQ accepts mail server address is pop.qq.com, Port 995String username= "18780279472";//Login server's accountString password= "wy87***";//This is not the client login password, but the authorization password must pay attention toSession session =mailutils.createsession (host, username, password); //Send mailString from = "[email protected]";//SenderString to = "[email protected]";//RecipientString title = "Test Message"; String content= "<a href= ' http://www.baidu.com ' > Baidu </a>"; Mail Mail=NewMail (from,to,title,content);            Mailutils.send (session, mail); }}

Javaweb Online Book Mall complete project--Send mail

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: info-contact@alibabacloud.com 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.