Gabe Dunn
Gabe Dunn

Reputation: 456

PHPMailer SMTP Connection Failed - GoDaddy

I am working on a website, and in it there is a form that is used to send email through gmail with PHPMailer.

I have it all set up correctly, because it works on my AWS EC2 server. However, when I use the exact same setup on a GoDaddy hosting plan, it doesn't work (yes, I changed 'require' paths).

I am getting this error:

Mailer Error: SMTP connect() failed.

Here is my code:

$mail = new PHPMailer;

$mail->SMTPDebug = 0;

$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "**********@gmail.com";
$mail->Password = "*************";
$mail->SMTPSecure = "tls";
$mail->Port = 587;

$mail->setFrom("**********@gmail.com", "Red's Mailer");
$mail->addAddress("*********@shaw.ca", "Name");

$mail->isHTML = true;

$mail->Subject = "New Submission From " . $name;
$mail->Body = $html_msg;
$mail->AltBody = $alt_msg;

Any ideas on the problem?

Upvotes: 1

Views: 10016

Answers (3)

vignesh Subash
vignesh Subash

Reputation: 2725

GoDaddy mail server does not support any email containing "FROM" header entry of aol, gmail, hotmail, yahoo, live, aim or msn.

If you are using linux cPanel hosting plan then you do need to change few lines in your php code and it will work!

$mail = new PHPMailer;
$mail->SMTPDebug = 0;
$mail->isSMTP();
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->ssl = false;
$mail->authentication = false;
$mail->addAddress("*********@shaw.ca", "Name");
$mail->isHTML = true;
$mail->Subject = "New Submission From " . $name;
$mail->Body = $html_msg;
$mail->AltBody = $alt_msg;

Upvotes: 5

Gabe Dunn
Gabe Dunn

Reputation: 456

I have found out why this isn't working - GoDaddy, for some reason doesn't like letting their clients using anyone else's SMTP servers, so you either have to use the email hosting provided by cPanel, which is extremely slow and inneficient.

What I've done instead is have the script hosted on an AWS ec2 instance and have the forms for the script post to that instead.

Upvotes: 1

Fencer04
Fencer04

Reputation: 1133

I had similar issues. GoDaddy does not allow SMTP outside using the emails with your domain. If you contact support your should get the same answer.

Upvotes: 1

Related Questions