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

PHP mail() WILL send - this is the simple solution

I have 3 PHP forms on my website - all use the PHP send() function, and all stopped working on GoDaddy's Windows server.  We also do not host our email at GoDaddy, but do have the domain registered with GoDaddy.  The forms work perfectly on Linux hosting.  After days of research, I figured out the solution below:


1. You need to create a SPF Record and add it to your domain records as a txt file.  For instructions on creating the SPF file for Gmail here is the link - However, no matter what email hosting you're using, the record you add will be very similar and will look like this -

v=spf1 ~all.  By adding this record, you're basically telling the server that it's safe to use your outside hosting to process email.


If you need help on adding it just search a little on GoDaddy's forums or wherever your domain is hosted, or contact tech support.  It's a quick and simple process.


2. Once you add this, it may take 24-48 hours to process - it did for me.


3. Back in your PHP form - Make sure that you designate a "From" email address ($From = '';) which matches the domain in the SPF Record.  So, if you added Google's mail servers in the SPF Record, make sure your "FROM" field in your form is something like "".


4. Finally, in your PHP form, make sure you add an ",-f .$From" to the end of your mail array so that if looks like this - 

mail($emailTo, $subjectTitle, $body, $headers, '-f'.$From);

This assures the server that your email is not spam.  


That's it!


I hope this helps some of you avoid the many painful hours I had to endure to finally figure this one out!

Community Manager
Community Manager

Re: PHP mail() WILL send - this is the simple solution

Fantastic @onlineinsite! Thanks so much for sharing all of this with other community members. It's so helpful. Take care!


All mail receiving in spam folder

I am receiving all mail in my spam folder. This is my code sample: Please help me on this



require_once "vendor/autoload.php";

$mail = new PHPMailer;

//Enable SMTP debugging.
$mail->SMTPDebug = 3;
//Set PHPMailer to use SMTP.
//Set SMTP host name
$mail->Host = "";
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = "";
$mail->Password = "super_secret_password";
//If SMTP requires TLS encryption then set it
$mail->SMTPSecure = "tls";
//Set TCP port to connect to
$mail->Port = 587;

$mail->From = "";
$mail->FromName = "Full Name";

$mail->addAddress("", "Recepient Name");


$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
$mail->AltBody = "This is the plain text version of the email content";

echo "Mailer Error: " . $mail->ErrorInfo;
echo "Message has been sent successfully";

Re: PHP mail() WILL send - this is the simple solution


Re: All mail receiving in spam folder

I've added a form to my Rapidweaver site, HTML Contact Form from Doobox. I set it to send to my account. I tested it and nothing has come through. From what I've found in the forum, it's a setting in Godaddy's cPanel but don't know where to look. I'd appreciate any advice on how to fix this.