PHPMailer&去吧爸爸 [英] PHPMailer & GoDaddy

查看:87
本文介绍了PHPMailer&去吧爸爸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题很简单:使用PHPMailer发送电子邮件,我遵守了哥达的规则:

My problem is simple: send an email with PHPMailer, i have followed the rules of godaddy:

$mail = new PHPMailer();
$mail->IsSMTP(); 
$mail->SMTP_AUTH = false;
$mail->Port = 25;
$mail->Host = "relay-hosting.secureserver.net"; 
$mail->FromName = "mycomercial@mycomercialemail.com.br"; 

$mail->SMTPDebug = 2;
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("mygmailemail@gmail.com");

if(!$mail->Send()) {
    echo "Error: " . $mail->ErrorInfo;
} else {
    echo "Message has been sent";
}

此代码是我在许多搜索的论坛中看到的代码,但是我仍然无法发送电子邮件,收到的内容是:

This code is what i have seen in many of the forums i searched for, but i still can't send the email, what i receive is:

2018-10-16 22:31:25 SMTP错误:无法连接到服务器:连接被拒绝(111)2018-10-16 22:31:25 SMTP connect()失败

2018-10-16 22:31:25 SMTP ERROR: Failed to connect to server: Connection refused (111) 2018-10-16 22:31:25 SMTP connect() failed

这是他们推荐的服务器?为什么我无法连接?谢谢大家的帮助

This is the server they recommend? why i cant connect? Thanks all for helping

推荐答案

好吧,我已经联系了goDaddy支持人员(非常好),他们说在服务器内部使用本地主机,所以我更改了代码,仍然无法正常工作,但至少已连接到服务器,并给了我错误:STARTTLS,在网络中搜索,我找到了此解决方案:

Well, i have contacted the goDaddy support(very good), they said to use localhost when inside their servers, so i changed my code, still didnt work, but at least connected to the server and gave me the error: STARTTLS, searching in the web i found this solution: solution

$mail = new PHPMailer(true);
$mail->IsSMTP(); // Using SMTP.
$mail->SMTPDebug = 1;
$mail->SMTPAuth = false; // Enables SMTP authentication.
$mail->Host = "localhost"; // GoDaddy support said to use localhost
$mail->Port = 25;
$mail->SMTPSecure = 'none';

//havent read yet, but this made it work just fine
$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);

$mail->AddReplyTo('comercial@email.com.br', 'Me');
$mail->AddAddress('my@gmail.com', 'Them'); 
$mail->SetFrom('comercial@email.com.br', 'Me');
$mail->Subject = 'PHPMailer Test Subject via smtp, basic with authentication';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML("Hi, this is an test email");
if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message has been sent";
}

最后,他们还给了我这个脚本: Github 以测试发送的电子邮件三种比较方式,但是此脚本发送的电子邮件可能会发送给您的垃圾邮件(第一个脚本正常),因此他们说,使用TXT记录和DNS配置某些内容是必需的,这是支持人员提供给我的数据:

To finilize, they also gave me this script: Github to test the email sending in three diff ways, but the emails this script send may go to your spam(the first script goes normal), so they said that is necessary to configure something with the TXT records and DNS, this is the data the support gave me:

添加TXT记录

Add TXT record

主持人:@

TXT值:v = spf1一个mx ptr包括:secureserver.net -all

TXT value :v=spf1 a mx ptr include:secureserver.net -all

TTL:1小时

但是我对此不确定,因为我不得不去看医生,所以我无法留下这个解决方案,谢谢大家.

But i dont know for sure about this, unffotunatelly, i couldnt stay for this solution as i had to go to the doctor, thanks all for att.

这篇关于PHPMailer&去吧爸爸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆