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();
}