Help, Registration emails go to spam inbox

4.4k views Asked by At

I just started offering user accounts on my website (large PR6 site, with a good reputation) and I noticed that the registration emails almost always go to the receivers spam box.

So far we have only sent out a few emails, so its not like we've been slamming out thousands.

I send the emails via PHP with the mail() function. Below you can find the headers that i send with the mail() function.

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers  .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers  .= 'From: Domain.com <[email protected]>' . "\r\n";

Is there a way, or a trick to get round these spam filters? Its clearly not spam what I am sending out. The registration email contains 3 links.

3

There are 3 answers

3
arnorhs On BEST ANSWER

There are many things that can cause emails to be flagged as spam. The solution is twofold: On one hand you should be using a good smtp server (deliverability) and then you should be forming your emails correctly. (A daunting task using mail().)

Sending emails correctly using PHP

You should really use something like PHPMailer. It's a php library for sending emails and does them properly, so the emails have a higher chance of reaching correctly.

http://phpmailer.worxware.com/

Email delivery

Email delivery can be a headache, but I can recommend http://www.sendgrid.com - You basically set them up as phpmailer's smtp server and use their outgoing mail server.. They're experts in email deliverability and you'll have a much easier time. Especially when you start sending out hordes of emails.

Code example

Example email from phpmailer's website:

<?php
require_once('../class.phpmailer.php');

$mail             = new PHPMailer();

$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug  = 2;  // enables SMTP debug information (for testing)
                                       // 1 = errors and messages
                                       // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "smtp.sendgrid.net"; // sets the SMTP server to sendgrid's server
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "[email protected]"; // Sendgrid user
$mail->Password   = "yourpassword";        // Sendgrid passw.

$mail->SetFrom('[email protected]', 'First Last');

$mail->AddReplyTo("[email protected]","First Last");

$mail->Subject    = "PHPMailer Test Subject via smtp, basic with authentication";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "[email protected]";
$mail->AddAddress($address, "John Doe");

echo !$mail->Send() ? "Mailer Error: " . $mail->ErrorInfo : "Message sent!";    
?>

I'd like to say that I'm not affiliated with Sendgrid in any ways. I'm just a big fan of their service. I fought with mail() function, smtp servers, mail queues and services for many years in web dev shop and I do not wish that fate for my worst enemy. Save yourself some time and worries.

Cheers...

0
JoeCool On

You probably have done this, but one thing I would check is that you have no key words in the email that would be a big red flag to a spam filter. Obviously, "registration" is necessary, but try avoiding other words that often show up in real spam. I'm sure spam filters are also sensitive to the number of links in an email, so slimming it down from 3 might be a good idea as well.

0
Chuck Morris On

Couple of tips from: http://pauldowman.com/2008/02/17/smtp-mail-from-ec2-web-server-setup/

If you are using a 3rd party smtp relay, like authsmtp, you should add spf record to your DNS.

spfwizard.com.

Don’t spoof the From field

You should only send mail from [email protected]. If you try to send mail from [email protected], for example, the receiver will see that pauldowman.com has an SPF record, and that it doesn’t authorize your mail server. Then into the spam folder you go.

To get around this you can send from something like [email protected], and set the Reply-To header to [email protected]. You can even set the name in the from field, for example: “Paul Dowman via yoursite” . The Reply-To header will make sure that most people’s replies go to the correct address, but a few will inevitably end up at [email protected] so it’s probably a good idea to set up an autoresponder at that address, or at least make sure the message bounces so the user eventually realizes the mistake.

And I second on using PHPMailer(). Takes care of a bunch of little things.