& Amp; lt ;? Php defines a mail sending function functionsendMail ($ address, $ title, $ message) {code...} if (! $ Mail-& amp; gt; Send () {code ...}} else {code ...}}} sendMail (& quot; 18501773419@163.com & quot;, & quot; Test & quot;, & quot; hi, my name is peace & quot ;);? & Amp; g...
// Define a mail sending Function
Function sendMail ($ address, $ title, $ message ){
// Import the mail file require (". /PHPMailer/class. phpmailer. php "); // create a mail object $ mail = new PHPMailer (); $ mail-> IsSMTP (); $ mail-> Host =" smtp.163.com "; $ mail-> SMTPAuth = true; $ mail-> Username = "18501773419@163.com"; $ mail-> Password = "x "; $ mail-> From = "18501773419@163.com"; $ mail-> FromName = "share weshare"; $ mail-> AddAddress ($ address); $ mail-> IsHTML (true ); $ mail-> Subject = $ title; $ mail-> Body = $ message;
If (! $ Mail-> Send ()){
return true;
} Else {
return false;
}
}
SendMail ("18501773419@163.com", "test", "Hello, I'm peace ");
?>
PHP uses phpmailer to send an email, prompting that The verification fails (SMTP Error: cocould not authenticate.). After The verification code is commented out, The following From address failed :?
Reply content:
// Define a mail sending Function
Function sendMail ($ address, $ title, $ message ){
// Import the mail file require (". /PHPMailer/class. phpmailer. php "); // create a mail object $ mail = new PHPMailer (); $ mail-> IsSMTP (); $ mail-> Host =" smtp.163.com "; $ mail-> SMTPAuth = true; $ mail-> Username = "18501773419@163.com"; $ mail-> Password = "x "; $ mail-> From = "18501773419@163.com"; $ mail-> FromName = "share weshare"; $ mail-> AddAddress ($ address); $ mail-> IsHTML (true ); $ mail-> Subject = $ title; $ mail-> Body = $ message;
If (! $ Mail-> Send ()){
return true;
} Else {
return false;
}
}
SendMail ("18501773419@163.com", "test", "Hello, I'm peace ");
?>
PHP uses phpmailer to send an email, prompting that The verification fails (SMTP Error: cocould not authenticate.). After The verification code is commented out, The following From address failed :?
You need to enable the SMTP service in the mailbox. You can set it in the mailbox ~ 163 the SMTP password should be assigned separately to the mailbox
(PS: use QQ mail to send messages. Note that the port number is not the default 25 !!!)
Class. smtp. php does not have require.
Check the environment log and improve the debug level of phpmailer.