PHPmailer在本地主機工作正常,但當它在服務器上顯示SMTP錯誤,以前它工作但罰款,但最近它不工作。這個問題發生在我的所有cPanel中,它可能是經銷商帳戶服務器問題嗎?我正在使用下面的代碼,並且出現如下錯誤: SMTP錯誤:無法進行身份驗證。phpmailer工作正常本地主機,但作爲服務器
function mail_sending($to_address, $to_name, $title_tag, $subject_tag, $mail_body)
{
$mail = new PHPMailer();
//End Code for adding a Page
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "myhost.com"; // sets the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "[email protected]"; // username
$mail->Password = "password";
$mail->SetFrom('[email protected]', $title_tag);
$mail->Subject = $subject_tag;
//End Attachments
//Start code for sending a html Body
$mail->IsHTML(true);
$mail->Body = $mail_body;
//End code for sending a html Body
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->AddAddress($to_address, $to_name);
$mail->Send();
}