PHPmailer 在 localhost 中工作正常,但在服务器上显示 SMTP 错误,以前它工作但很好,但最近它不工作。这个问题出现在我所有的 cPanel 中,可能是经销商帐户服务器问题吗?我正在使用下面的代码,我收到如下错误:SMTP 错误:无法验证。
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 = "admin@myhost.com"; // username
$mail->Password = "password";
$mail->SetFrom('admin@myhost.com', $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();
}