cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Go to solution
Highlighted

PHPMailer Mail Sending Error

I am a fresher in Godaddy. I just hosted a php website in this server. 

 

In my website, i added a mail sending form. The mail is sending through smtp.gmail.com host server the port i used is 465. 

But when i host my website in this server, the mail sending module shows an SMTP connect error.

"SMTP ERROR: Failed to connect to server: Connection refused (111) 2018-09-29 15:19:15 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mail error: SMTP connect() failed".

 

Also i tested the code with relay-hosting.secureserver.net instead of smtp.gmail.com and the port 25. But it's not working and showing the same error. 

 

Please help me to solve this error.

 

10 REPLIES 10
Community Manager
Community Manager

Re: PHPMailer Mail Sending Error

Hi @Pooja-php. Thanks for being part of GoDaddy Community! Trying to send from a 3rd party email server would definitely cause that error. I'm not sure why you'd still be seeing it if you're using relay-hosting.secureserver.net though. You may want to post your code here so others can take a look at it. That may help you get a response. 

 

JesseW - GoDaddy | Community Manager | 24/7 support available at x.co/247support | Remember to choose a solution and give kudos.

Re: PHPMailer Mail Sending Error

Hai,

 

    Here i am attaching the code. I don't know what is the issue. Some times mail sending properly. Other times it will not send the mail. Sometimes it goes to spam box and other times it goes to inbox 

 

<?php
require 'phpmailer/PHPMailerAutoload.php';

if(isset($_POST["sbmt"]))
{

$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];

$section=array();
$time=array();
$to= "sppooja909@gmail.com";
$subject="Enquiry";
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 2; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = false; // authentication enabled
$mail->SMTPSecure = 'none'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = '*********.prod.iad2.secureserver.net';
$mail->Port =25;
$mail->Username = "user@gmail.com";
$mail->Password = "*********";
$mail->SetFrom($email,$name,$email);
$mail->Subject = "Contact Us Mail";
$mail->AddAddress($to);
$mail->AddReplyTo("$email");
$mail->Body = "Dear ,"."\n\n\n\n"."Subject:"."\t".$subject."\n\n"."Comment:"."\t".$comment."\n\n\n"."User Details"."\n\n"."Name:"."\t"."$name"."\n\n"."Email:"."\t"."$email";
if(!$mail->Send()) {

$error = 'Mail error: '.$mail->ErrorInfo;
echo $error;
} else {

?>
<script>
window.location='index.php';
alert("Thank you for your query. We will catch you soon");
</script>
<?php
}

}
?>

Community Manager
Community Manager

Re: PHPMailer Mail Sending Error

@Pooja-php - The host in your script above seems to be sending from something other than relay-hosting.secureserver.net. You'll want to change that. You can also leave off the username and password as the server does not require authentication. There might be other issues too, but I'm not a PHP developer and can't really critique the code. 

 

As for the message landing in a spam folder, you'll want to make sure you're sending mail from an address that is specific to your site's domain (ie address@domain.com). You'll also want to make sure you have an SPF record for the domain that specifies you can send from secureserver.net. 

 

JesseW - GoDaddy | Community Manager | 24/7 support available at x.co/247support | Remember to choose a solution and give kudos.

Re: PHPMailer Mail Sending Error

Hai,

 

  First i tried with relay-hosting.secureserver.net  and localhost as the host name. But that time the phpmailer shows an smtp connect() failed error. Then i searched through the community Posts related to my problem and i got a solution. My mails are  sending only with the cpanel name as given in the host . But the sending mails are goes to the spam box. 

 

My domain and server are in godaddy. So how can i setup SPF record? 

Community Manager
Community Manager

Re: PHPMailer Mail Sending Error

@Pooja-php - Using v=spf1 include:secureserver.net –all for the domain's SPF should allow you to send emails from any of our services. If that doesn't help, then it would be difficult to determine why your messages are delivered as spam. You may want to see if your recipients can find out why this is happening by contacting their mail provider. If the addresses you're sending to are using our email services, then our advanced support can usually look up what is happening to email messages if you can give them the exact email address and the time/date mail was sent. Our customer care team can connect with our advanced team, so you may want to get in touch with them regarding this. 

 

JesseW - GoDaddy | Community Manager | 24/7 support available at x.co/247support | Remember to choose a solution and give kudos.
Solution

Re: PHPMailer Mail Sending Error

Hai,

 

      I Configured the SPF record like

TXT@v=spf1 mx -all31557600 seconds

 

First the mail is goes to the primary inbox. But after that, all mails goes to spam box. I don't know why it is like that. I don't know any further configuration is needed or current configurations are wrong. Could you please check my cpanel configurations?

 

Community Manager
Community Manager

Re: PHPMailer Mail Sending Error

@Pooja-php - Based on the script you provided, it seems that you're sending to a Gmail account. If the mail is being delivered but filtered to spam on the Gmail end, you may need to do some troubleshooting with their support. I'm not sure what would cause that either. Sorry Man Sad

 

JesseW - GoDaddy | Community Manager | 24/7 support available at x.co/247support | Remember to choose a solution and give kudos.

Re: PHPMailer Mail Sending Error

Hai,

So how can I solve this problem? . There is no solution for this issue?

Re: PHPMailer Mail Sending Error

Hi Pooja,

 

If you have office 365 email manager in your GoDaddy account,  try smtp.office365.com port 587 (ssl port)


Regards

Re: PHPMailer Mail Sending Error

Hai irvjtorres,

 

        I don't have office 365 email manager in my GoDaddy account.