【问题标题】:Sending mails using PHPmailer is not working on a live server使用 PHPmailer 发送邮件在实时服务器上不起作用
【发布时间】:2017-10-06 01:43:01
【问题描述】:

如果我使用 Gmail smtp 凭据正常工作,但在上线服务器后它就无法正常工作。当我使用 godaddy 网络邮件时,它在本地主机或实时服务器上不起作用。

这是我的 PHP 文件。

<?php
    $data = json_decode(file_get_contents("php://input"));
    $Cust_Email = $data->Cust_Email;
    $result = array();
require 'vendor/PHPMailerAutoload.php';

$mail = new PHPMailer;


$mail->isSMTP();                                   
$mail->Host = 'relay-hosting.secureserver.net';  
$mail->SMTPAuth = true;                              
$mail->Username = 'orders@washbucket.info';                 
$mail->Password = '******';                           
$mail->SMTPSecure = 'ssl';                           
$mail->Port = 25;                                    

$mail->setFrom('orders@washbucket.info', 'Admin');
$mail->addAddress($Cust_Email);    

$mail->isHTML(true);                                  

$mail->Subject = 'Welcome To User.';
$mail->Body    = 'This is greating from Admin';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
     $result = '_FAIL';
} else {
    $result = '_SUCCESS';
}

echo json_encode($result);
?>

【问题讨论】:

  • 使用此代码并获取调试数据并阅读您的代码或托管中的问题 $mail->SMTPDebug = 2;

标签: php email phpmailer sendmail


【解决方案1】:

对端口 25 使用隐式 SSL 根本不起作用。设置SMTPSecure = false。如果服务器支持,PHPMailer 将自动启用显式 TLS。如果我没记错的话,GoDaddy 不会对其中继服务器使用身份验证,因此您可能还需要设置 SMTPAuth = false

【讨论】:

    猜你喜欢
    • 2020-05-09
    • 2015-06-04
    • 1970-01-01
    • 2011-06-07
    • 1970-01-01
    • 1970-01-01
    • 2021-09-27
    • 2018-05-14
    • 1970-01-01
    相关资源
    最近更新 更多