Phpmailer mail sending instance (163 mailbox 126 mailbox yahoo mailbox)

Source: Internet
Author: User

Preparations:

You must register an email address (163 mailbox, 126 mailbox, yahoo mailbox).

Notes

These mailboxes must support login and sending. We do not configure these mailboxes.

163 email $ mail-> Host = "smtp.163.com ";


126 email $ mail-> Host = "smtp.126.com ";


Yahoo mail $ mail-> Host = "smtp.mail.yahoo.com.cn ";

You must write your own username and password in the same way in other places.

I use 163 email as an instance.

The code is as follows: Copy code

<? Php
Require_once ('../class. phpmailer. Php ');
$ Mail = new PHPMailer ();
$ Body = "I finally sent the email! Haha! <Br/> ";
// Use SMTP to send emails
$ Mail-> IsSMTP ();
// Email server
$ Mail-> Host = "smtp.163.com ";
$ Mail-> SMTPDebug = 0;
// Use SMPT for verification
$ Mail-> SMTPAuth = true;
// SMTP-verified user name
$ Mail-> Username = "******** @ 163.com ";
// SMTP Authentication secret
$ Mail-> Password = "***";
// Set the encoding format
$ Mail-> CharSet = "UTF-8 ";
// Set the topic
$ Mail-> Subject = "test ";
// $ Mail-> AltBody = "To view the message, please use an HTML compatible email viewer! ";
// Set the sender
$ Mail-> SetFrom ('***** @ 163.com', 'test ');
// Send emails in html format
$ Mail-> MsgHTML ($ body );
// Recipient's email name
$ Mail-> AddAddress ("*** @ 163.com"," test "); // send an email
If (! $ Mail-> Send ()){
Echo "Mailer Error:". $ mail-> ErrorInfo;
} Else {
Echo "Message sent! ";
}

Note that the red area is changed based on your own needs.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.