Why can't I receive emails if the email is sent? & Lt ;? Phprequire 'class. phpmailer. php'; try {$ mail = newPHPMailer (true); // Newinstance, withexceptionsenabled $ body: why can't I receive emails when I send emails?
Require 'class. phpmailer. php ';
Try {
$ Mail = new PHPMailer (true); // New instance, with exceptions enabled
$ Body = file_get_contents('contents.html ');
$ Body = preg_replace ('// \\\/', '', $ body); // Strip backslashes
$ Mail-> IsSMTP (); // tell the class to use SMTP
$ Mail-> SMTPAuth = true; // enable SMTP authentication
$ Mail-> Port = 25; // set the SMTP server port
$ Mail-> Host = "smtp.qq.com"; // SMTP server
$ Mail-> Username = "wanglintao_1@qq.com"; // SMTP server username
$ Mail-> Password = "12345in"; // SMTP server password
$ Mail-> IsSendmail (); // tell the class to use Sendmail
$ Mail-> AddReplyTo ("name@domain.com", "First Last ");
$ Mail-> From = "wanglintao_1@qq.com ";
$ Mail-> FromName = "wanglingtao ";
$ To = "wanglintao_1@163.com ";
$ Mail-> AddAddress ($ );
$ Mail-> Subject = "First PHPMailer Message ";
$ Mail-> AltBody = "To view the message, please use an HTML compatible email viewer! "; // Optional, comment out and test
$ Mail-> WordWrap = 80; // set word wrap
$ Mail-> MsgHTML ($ body );
$ Mail-> IsHTML (true); // send as HTML
$ Mail-> Send ()
Echo "Message has been sent ";
} Catch (phpmailerException $ e ){
Echo $ e-> errorMessage ();
}
?>
------ Solution --------------------
Are you sure you have activated SMTP/pop3 on QQ?
------ Solution --------------------
Check whether the email receiving program is running on your server.
------ Solution --------------------
Check whether the log sent by the server mail is usually in/var/log/maillog
------ Solution --------------------
Discussion
$ Mail-> Host = "smtp.qq.com"; // SMTP server
$ Mail-> Username = "wanglintao_1@qq.com"; // SMTP server username
$ Mail-> Password = "12345in"; // SMTP server password
====================================
Excuse me ......
------ Solution --------------------
Change the password to 126. Try gmail. Qq is not supported.
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.