PHPMailer,godaddy托管上的SMTP错误

时间:2018-04-12 18:29:53

标签: smtp phpmailer

我知道这个问题已被多次回答,但是godaddy在2018年初进行了一些配置更改,我无法使我的网络表单起作用。

我试图通过来自godaddy上托管的网页的联系表单与PHPMailer发送电子邮件。

我正在使用gmail SMTP配置:

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "sender@gmail.com";
$mail->Password = "************";
$mail->AddReplyTo(sender@gmail.com);
$mail->SetFrom(sender@gmail.com);
$mail->From = sender@gmail.com;
$mail->FromName = Sender Name;
$mail->AddAddress(username@domain.com);
$mail->Subject = utf8_encode("=?UTF-8?B?" . base64_encode("Email text") . "?=");
$mail->MsgHTML("Message");
$mail->WordWrap = 450;
$mail->IsHTML(true);
$mail->Send();

这是我收到的错误:

SMTP ERROR: Failed to connect to server: Connection refused (111) 2018-04-12 17:08:56   SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 
Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting   

我已经尝试过网络搜索问题,查看PHPMailer疑难解答并更改配置参数,但仍然无法使其正常工作。调用godaddy也没用,他们说这是代码错误。

相同的代码适用于localhost和其他托管。

提前致谢。

2 个答案:

答案 0 :(得分:0)

要使用邮件程序,您必须在周日创建电子邮件

关注 $ mail-> IsMail();

$mail = new PHPMailer;
$mail->IsMail();        // Set mailer to use  NONE SMTP
$mail->Host = 'mail.vedantaxyz.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = false;                               // Enable SMTP authentication
$mail->Username = 'manoj@vedantaxyz.com';                 // SMTP username
$mail->Password = 'password';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25;        

$mail->setFrom($adminemail, $appname);
$mail->addAddress($reciveremail, 'Hello - Forgot Password');     // Add a recipient

$mail->addReplyTo($adminemail, $appname);
$mail->isHTML(true);                                  // Set email format to HTML
$mail->Subject = 'Hello- Forgot Your Password';
$body = "<b>Body here</>";
$mail->Body    = $body;
$mail->AltBody = '';

if(!$mail->send()) {
    echo $mail->ErrorInfo;
    echo (json_encode(['status'=>true,'msg'=>'Mail sent to your email']));
} else {
    echo (json_encode(['status'=>false,'msg'=>'Mail not sent']));
}

答案 1 :(得分:-1)

解决!

只需要更改$ mail-&gt; IsSMTP(); $ mail-&gt; IsMail();