PHPMailer GoDaddy Server SMTP Connection Refused

2019-01-03 02:36发布

The other day I was experiencing some problems with my GoDaddy hosted site. I called their tech support, and the person that I spoke with suggested that my problems were related to the fact that I was on a Windows box and would be better served on a Linux box. Having no opinion on this, I agreed and they switched me over.

In the wake of that transition, my PHPMailer functionality has deserted me. I have had this working for months, so I know that my settings are accurate. I have confirmed with GoDaddy that the account I am trying to send out of has not changed from their perspective. No changes have been made on the user side (like a new password). Bottom line, the only thing that is different is that my site is now hosted on a Linux server. That's it.

So I assume that my PHPMailer difficulties must be related to that, since it is too much of a coincidence that a script that has worked for months fails at the exact moment that the server transition occurs. But why? I spent an hour with their tech support, and they see nothing wrong with the server settings. We verified my settings (just for fun). Everything looks good, but when I send an email, I get this error:

SMTP -> ERROR: Failed to connect to server: Connection refused (111)SMTP Connect() failed.

There are many posts about this type of error, and almost all of them relate to people getting set up for the first time who have mis-entered settings or omitted settings. However, I KNOW that my settings are complete and accurate since I've been using them successfully for months. I'll post them here just for completeness:

$mail = new PHPMailer();
$mail->IsSMTP();  //telling the class to use SMTP
$mail->isHTML(true);
$mail->Host         = "smtpout.secureserver.net"; //also tried "relay-hosting.secureserver.net"
$mail->WordWrap     = 50;
$mail->SMTPAuth     = true;
$mail->SMTPSecure   = "ssl";
$mail->Port         = 465;
$mail->Username     = "example@email.com";
$mail->Password     = *******;
$mail->Subject      = "Test Email";
$mail->SMTPDebug = 1;

Does anyone have any ideas why this might be happening? Is there some server setting that the tech support people might not be aware of, like maybe in my php.ini file? The guy I worked with did his best to help me out, but he may just not be aware of something.

Any help is appreciated. Let me know if there is any other information I can provide. Thanks!

EDIT: I should also mention some of the other attempts that I made. I get the same result no matter what.

1) TLS with port 587 2) Without SSL using ports 25, 80, and 3535. 2) My own gmail address modifying the server, username, password, etc.

18条回答
可以哭但决不认输i
2楼-- · 2019-01-03 03:15

these will be your SMTP settings for GoDaddy:

require("PHPMailer-master/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug  = 2;
$mail->From = "yourmail@ffffd.com";
$mail->FromName = "name";
$mail->Host = "localhost"; 
$mail->SMTPAuth = false; 
$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;
查看更多
放我归山
3楼-- · 2019-01-03 03:16

GoDaddy/Linux (cPanel)/PHPMailer

require_once("../include/PHPMailer-master/PHPMailerAutoload.php");

$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host         = "a2plcpnXXXXX.prod.iad2.secureserver.net";
$mail->SMTPDebug    = 2; 
$mail->SMTPAuth     = true;
$mail->Username     = "your username";
$mail->Password     = "your password";
$mail->SMTPSecure   = "tls";
$mail->Port         = 587;

Feel free to use whatever email/name you want for the $mail->From and $mail->FromName values. Hope this helps.

查看更多
甜甜的少女心
4楼-- · 2019-01-03 03:22

I'm on GoDaddy on a Linux like @surfbird0713. On my 32nd attempt, the following worked for me as well:

$mail2->Host = localhost;
//$mail2->SMTPAuth = false;
//$mail2->Username = 'xxxx@xxxxxx.com';
//$mail2->Password = '*******';

//$mail2->SMTPSecure = 'tls';

//$mail2->Port = 465;

I was previously trying with the username, login, port, etc. When I commented out all those, and just went with localhost it worked.

查看更多
beautiful°
5楼-- · 2019-01-03 03:23

According to Godaddy, replace

$mail->Host = "smtpout.secureserver.net"; //also tried "relay-hosting.secureserver.net"

with

$mail->Host = "smtp.secureserver.net"; //also tried "relay-hosting.secureserver.net"

It worked for me.

查看更多
小情绪 Triste *
6楼-- · 2019-01-03 03:24

After a lot of frustration, this also worked for me.

include("includes/class.phpmailer.php");

date_default_timezone_set('UTC');

define('SMTP_HOST','relay-hosting.secureserver.net');
define('SMTP_PORT',25);**
define('SMTP_USERNAME','me@aravindnc.com');
define('SMTP_PASSWORD','me123');
define('SMTP_AUTH',false);

$email = 'aravind_n_c@yahoo.co.in';
$firstName = 'Aravind';

$mail = new PHPMailerR();
$mail->IsSMTP();
$mail->SMTPDebug = 1;                 
$mail->SMTPAuth = SMTP_AUTH;                
$mail->Host = SMTP_HOST;
$mail->Port = 25;
$mail->Username = SMTP_USERNAME;
$mail->Password = SMTP_PASSWORD;
$mail->SetFrom(SMTP_USERNAME,'AravindNC.IN');
$mail->AddReplyTo(SMTP_USERNAME,"AravindNC.IN");
$mail->Subject = "Welcome to AravindNC.IN";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML('This is a test.');
$mail->AddAddress($email, 'Aravind NC');
$mail->Send();

?>
查看更多
Anthone
7楼-- · 2019-01-03 03:25

If using cPanel and WPForms in WordPress

What helped me is to create email address from cPanel and use its settings from Manual Settings section either with SSL or Non SSL

enter image description here

查看更多
登录 后发表回答