The phpmailer local test prompts that the message is successfully sent, but the email cannot receive the message.

Source: Internet
Author: User
The phpmailer local test prompts that the message is successfully sent, but you cannot receive it in your mailbox. please kindly advise, & lt ;? Php & nbsp; require_once ('class. phpmailer. php '); require_once ("class. smtp. php "); & nbsp; $ mail & phpmailer: the local test shows that the message is successfully sent, but the email cannot receive the message.
Could you give me some advice,

Require_once ('class. phpmailer. php ');
Require_once ("class. smtp. php ");
$ Mail = new PHPMailer ();

$ Mail-> CharSet = "UTF-8"; // sets the mail encoding, the default ISO-8859-1, which must be set to UTF-8 if you send Chinese
$ Mail-> IsSMTP (); // you can specify the SMTP service.
$ Mail-> SMTPAuth = true; // enable SMTP verification
$ Mail-> SMTPSecure = "ssl"; // SMTP Security Protocol
$ Mail-> Host = "smtp.163.com"; // SMTP server
$ Mail-> Port = 465; // SMTP server Port number
$ Mail-> Username = "123456@163.com"; // SMTP server Username
$ Mail-> Password = "123456"; // SMTP server Password
$ Mail-> SetFrom ('1970 @ 163.com ', '20160901'); // you can specify the sender address and name.
$ Mail-> AddReplyTo ("123456@163.com", "123456 ");
// Set the email reply recipient's address and name
$ Mail-> Subject = ''; // you can specify the mail title.
$ Mail-> AltBody = "to view this email, switch to an HTML-supported email client ";
// Optional, backward compatibility considerations
$ Mail-> MsgHTML ('Hello, simplified, traditional !!'); // Set the email content
$ Mail-> AddAddress ('1970 @ 163.com ', "123456 ");
$ Mail-> SMTPDebug = true;
// $ Mail-> AddAttachment ("images/phpmailer.gif"); // attachment
If (! $ Mail-> Send ()){
Echo "failed to send:". $ mail-> ErrorInfo;
} Else {
Echo "congratulations, the email is sent successfully! ";
}
?>

------ Solution --------------------
$ Mail-> Port = 465; // SMTP server Port number
Why not use port 25?
------ Solution --------------------
Comment out the two sentences
$ Mail-> SMTPSecure = "ssl"; // SMTP Security Protocol
$ Mail-> Port = 465; // SMTP server Port number

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.