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();
}
答案 0 :(得分:0)
从错误消息中可以看出本地服务器在发送任何邮件之前需要身份验证信息。
你可以像这样指定所说的信息:
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = “email@domain.com”; // SMTP username
$mail->Password = “password”; // SMTP password
username
和password
应该是您从托管服务提供商那里获得的有关smtp使用的信息,我相信他们会获得常见问题解答或者可以帮助您。
答案 1 :(得分:0)
确保在服务器中启用了OpenSSL:
1. Login through WHM with your root account;
2. Select or search for "EasyApache (Apache Update)";
3. Select "Start customizing based on profile";
4. Select "Next step";
5. Select "Next step";
6. Select "Next step";
7. Select "Exhaustive Options List";
8. Select "OpenSSL";
9. Select "Save and Build" and choose "Yes" in the following questions.
更多信息:http://forums.cpanel.net/f5/enable-php-openssl-machine-whm-cpanel-222991.html