PHP on GoDaddy Linux Jointly trying to send via gmail SMTP

I tried EVERY single script / code / method posted on StackOverflow and other sites for this, but with no luck. I go to GoDaddy. I set up a Google App account, set up everything necessary for MX records (using the GoDaddy tool for this) and even tried to send some messages from the GMAIL interface for my site, as well as via SMTP in the terminal on one of my unix machines. It all worked.

HOWEVER, when I try to use PHP, it is not! Does GoDaddy seem to be blocking it somehow?

I always get:

SMTP → ERROR: Could not connect to server: Connection refused (111) SMTP Error: Could not connect to the SMTP host. Mailer error: SMTP error: Could not connect to the SMTP host.

Here is the code I'm using for PHPMailer:

<html> <head> <title>PHPMailer - SMTP (Gmail) advanced test</title> </head> <body> <?php require_once('../class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch $mail->IsSMTP(); // telling the class to use SMTP try { $mail->Host = "smtp.gmail.com"; // SMTP server $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Username = "MYFROMADDRESSHERE"; // GMAIL username $mail->Password = "MYFROMPASSWORDHERE"; // GMAIL password $mail->AddReplyTo('MYFROMADDRESSHERE', 'Sender Name'); $mail->AddAddress('TESTTOADDRESSHERE', 'Recipient Name'); $mail->SetFrom('MYFROMADDRESSHERE', 'Sender Name'); $mail->AddReplyTo('MYFROMADDRESSHERE', 'Sender Name'); $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically $mail->MsgHTML(file_get_contents('contents.html')); $mail->AddAttachment('images/phpmailer.gif'); // attachment $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment $mail->Send(); echo "Message Sent OK</p>\n"; } catch (phpmailerException $e) { echo $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! } ?> </html> 

Thanks!

+8
php phpmailer smtp gmail
source share
11 answers

As discussed earlier, GoDaddy is known to block outgoing SSL SSL connections in favor of forcing you to use your own outgoing mail server.

This is largely the tip of the iceberg, due to GoDaddy's tremendous pleasure as a company, registrar, and web host. Ditch'em.

+22
source share

I had the same problem, and going through different sites, I found this one and it really worked!

GoDaddy allows you to send emails using Gmail as your SMTP, you just need to get rid of smtp.gmail.com and use your own host instead. This is my setup:

 $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = "relay-hosting.secureserver.net"; $mail->Username = "your-account@gmail.com"; $mail->Password = "yourpassword"; // ... // send from, send to, body, etc... 

Link (see first two posts) http://support.godaddy.com/groups/web-hosting/forum/topic/phpmailer-with-godaddy-smtp-email-server-script-working/

+7
source share

I finally fixed this by adding a comment to the line //$mail->isSMTP(); . After that, my Gmail account started working fine in Godaddy.

 require 'PHPMailer/class.phpmailer.php'; require 'PHPMailer/PHPMailerAutoload.php'; $mail = new PHPMailer; $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $subject = 'Your subject'; $body = "From: $name\n E-Mail: $email\n Comments:\n $message"; //$mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'xxxxxxxxxxxx@gmail.com'; $mail->Password = 'xxxxxxxxx'; $mail->SMTPSecure = 'tls'; $mail->Port =587; 
+3
source share

Use localhost as the host on your goDaddy hosting server. Using the following ports is 25 465 587. Settings for GoDaddy:

The answer relates to this link: Disabling the SMTP connection PHPMailer GoDaddy by @Nate Bryam

  $this->mail->Host = 'localhost'; //$this->mail->SMTPAuth = true; //$this->mail->Username = 'xxx@gmail.com'; //$this->mail->Password = 'xxx'; //$this->mail->SMTPSecure = 'ssl'; //$this->mail->Port = 465;//25;//587; 

No need for SMTP Auth.It works great!

+2
source share

Unfortunately, you cannot even use an outgoing mail service, such as DYNDNS, with GoDaddy, they only allow you to use a relay server. Restriction.

+1
source share

The only thing they have is to use a domain and use their email service to send mail.

+1
source share

require_once ('PHPMailerAutoload.php');

  $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = "relay-hosting.secureserver.net"; $mail->Username = 'chandana@gmail.com'; $mail->Password = 'fwxnorhqttkxydr'; $mail->SetFrom($email); $mail->Subject = 'enquiry from YnRack site'; $mail->Body = 'enquiry from YnRack site' . $message . '"From: \"' . $name . $email; $mail->IsHTML(true); $mail->AddAddress('chandana@gmail.com'); $mail->Send(); 
+1
source share

I do not support Godaddy because they usually suck, but it works for me. Perhaps they updated the system.

 $mail = new PHPMailer(); // create a new object $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail $mail->Host = "smtp.gmail.com"; $mail->Port = 587; // or 587 or 465 $mail->IsHTML(true); $mail->Username = "stuff@gmail.com"; $mail->Password = "password"; $mail->setFrom('gmail_account@gmail.com', 'Someone name'); $mail->Subject = $subject; $mail->Body = $body; $mail->AddAddress("gmail_account@gmail.com"); if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; return false; } else { return true; } } 

Oh, I also want everyone, I don't care about OOP !!!

0
source share

you can use your gmail and enable Godaddy Remote Mail Exchanger in cpanel. You should ask them to do this because you do not have access to it in cpanel

0
source share

Here is some info: http://aravindisonline.blogspot.in/2012/01/phpmailer-with-godaddy-smtp-email.html

This works for me:

 $mail->Host = "relay-hosting.secureserver.net"; //Set the SMTP port number - likely to be 25, 465 or 587 $mail->SMTPSecure = 'tsl'; $mail->Port = 25; //Whether to use SMTP authentication $mail->SMTPAuth = false; 
0
source share

Simpler. strange you need a comment line "// $ mail-> IsSMTP ();". Yes, fine, its SMTP, but if you enable this line, you will not be able to send mail. ... no more configuration needed. Just this line of comment.

0
source share

All Articles