2012-10-15 137 views
1

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

回答

0

从它出现在本地服务器需要认证信息错误信息之前,让我们发送的任何邮件。

您可以指定的信息是这样说:

$mail->SMTPAuth = true; // turn on SMTP authentication 
$mail->Username = “[email protected]”; // SMTP username 
$mail->Password = “password”; // SMTP password 

usernamepassword应该是你方关于SMTP使用您的托管服务提供商得到的,我相信他们得到的常见问题,也可以帮助你。

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

相关问题