8

I am using PHPMailer to send a confirmation email for newly registered users in my social network. But I found out most of them have ended up in user's spam list. (Hotmail and Yahoo). How to avoid this?

This is my script

$mail=new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = mSMTPAuth(); 
$mail->SMTPSecure = mSMTPSecure(); 
$mail->Host = mHost(); 
$mail->Port = mPort(); 
$mail->Username = mUsername(); 
$mail->Password = mPassword(); 
$mail->From = mFrom();
$mail->FromName = "SiteName";
$mail->Subject = "SiteName New Account Activation";
$mail->IsHTML(true); 
$mail->WordWrap = 50;       

$mail->Body = "<h2>Welcome to " .$sitename. " " .$username. "! </h2><br><br>";
$mail->Body .= "Please click on the link below to verify your email address:<br><br>";
$mail->Body .= "<a href='".$base. "verify.php?a=" .$gen_key."'>".$base. "verify.php?a=" .$gen_key."</a>";
$mail->Body .= "<br><br>Regards<br>";

$mail->AltBody = "Welcome to " .$sitename. " " .$username. "!\n\nTo verify your email address, please click on the link below:\n\n".$base. "verify.php?a=" .$gen_key;

$mail->AddAddress($email);
$mail->Send();
$mail->ClearAddresses();
Veger
  • 37,240
  • 11
  • 105
  • 116
praveen
  • 83
  • 1
  • 5

6 Answers6

5

To maximize the odds of your email arriving, there are three things you need to check:

  1. Make sure the computer sending the email has a Reverse PTR record
  2. Configure DomainKeys Identified Mail (DKIM) in your DNS and code
  3. Set up a SenderID record in your DNS

details at:

http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html

Jeff Atwood
  • 63,320
  • 48
  • 150
  • 153
3

There's not much you can do about it. Most of those mail providers have lists of common IP addresses, hostnames, and other data that often get flagged as spam and if your emails match the criteria they automatically get filtered. All you can really do is tell your visitors to add your email address to their allow list before registering so the email will go through to their inbox.

Honestly, don't worry about it. If they see your emails are regularly being marked as 'not spam' then they'll eventually add an exception for it. Just tell users to check their spam folder if they don't see the email like every other site does. Usually if they mark it as 'not spam' in that folder it will automatically add an exception for that address so any other emails you send them will end up in their inbox.

animuson
  • 53,861
  • 28
  • 137
  • 147
3

Do you have a reverse DNS entry for the server sending the confirmation e-mails?

If not, this might be a rDNS issue. Some sites are much more likely to mark a message as SPAM if the IP and name of the sending host don't match according to rDNS.

Otherwise, you might try sending confirmation e-mails to your own accounts on major e-mail sites like yahoo, hotmail and g-mail and then tweaking the wording until it gets past the spam filters.

dmcer
  • 8,116
  • 1
  • 35
  • 41
  • Thanks a lot for replying. I have also setup SPF records for my domain. I'm using google hosted mail SMTP to send mails. Sorry i couldn't mention that. I have no idea about reverse DNS. – praveen Mar 20 '10 at 12:36
  • If you're using Google to send the e-mails, you don't have to worry about rDNS issues. Does your SPF record contain include:aspmx.googlemail.com? If not, that may be the problem - see http://www.google.com/support/a/bin/answer.py?hl=en&answer=33786 . – dmcer Mar 20 '10 at 23:03
0

Hm, there is SOMETHING you can do: * Scrap the HTML. This looks like spam, especially with low text * Write some more text, please.

Short HTML mails may rise up quite on the spam list.

TomTom
  • 61,059
  • 10
  • 88
  • 148
  • What if i use "SMTP relay" ? Are there any reasonable/cheap SMTP relay service providers? Thanks – praveen Mar 20 '10 at 12:50
  • Wont really help content analysis. Short HTML email looks fishy. I get ton of those, and mostely they have a big pictue trying to sell me software or viagra ;) – TomTom Mar 20 '10 at 13:21
  • send the content through a verifier like check-auth@verifier.port25.com to see if it passes the spam-assassin check (as well as DKIM, SPF, and Sender-ID) – Jeff Atwood Apr 21 '10 at 11:23
0

I discovered that any variation of the word "confirm" in the title ends up in my spam bucket. I found other words that also do this: "purchase", "hurry", "order", "bargain", and "imminent".

This may not be true in all emails, but it happens in mine. It may be because those words appear in most of the emails I mark as span. It also may be that a local sysop made a filter and distributed it to all of us.

midimagic
  • 45
  • 1
0

You can try using sendGrid apis which will helps, they charge but I think it is worthy. They support most popular languages : Nodejs, PHP, Java, ....

aidonsnous
  • 1,475
  • 4
  • 19
  • 41