Send email using PHPMailer on GoDaddy hosting

  sonic0002        2018-11-16 08:28:55       16,740        2    

According to PHPMailer troubleshooting guide, GoDaddy has a very strict rule on sending email using PHPMailer.

Popular US hosting provider GoDaddy imposes very strict (to the point of becoming almost useless) constraints on sending an email. They block outbound SMTP to ports 25, 465 and 587 to all servers except their own. This problem is the subject of many frustrating questions on Stack Overflow. If you find your script works on your local machine, but not when you upload it to GoDaddy, this will be what's happening to you. The solution is extremely poorly documented by GoDaddy: you must send through their servers, and also disable all security features, username, and password (great, huh?!), giving you this config for PHPMailer:

The solution provided is:

$mail->isSMTP();
$mail->Host = 'relay-hosting.secureserver.net';
$mail->Port = 25;
$mail->SMTPAuth = false;
$mail->SMTPSecure = false;

Somehow it is not working now which may be that GoDaddy has made update on their rules. The new code which could work is.

$mail->isSMTP();
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->SMTPAuth = false;
$mail->SMTPSecure = false;

The only change needed is that the Host is changed to localhost. With this, it will try to connect to the mail service hosted at the same server as the web application and using port 25.

If you want to debug the error while testing send email, you can turn on the flag by setting below which will print the detailed client server communication.

$mail->SMTPDebug  = 3;  

Hope this helps someone who encounters similar issue.

PHP  GODADDY  PHPMAILER 

       

  RELATED


  2 COMMENTS


Anonymous [Reply]@ 2019-03-25 14:47:51

I try this but not send!!!! :(

Ke Pi [Reply]@ 2019-03-27 08:48:05

Have u tried to debug by enabling the debug flag?



  RANDOM FUN

When rookie fixes bug the first time