Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Account confirmation email sent as SPAM

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();
like image 225
praveen Avatar asked Mar 20 '10 06:03

praveen


2 Answers

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

like image 68
Jeff Atwood Avatar answered Sep 23 '22 07:09

Jeff Atwood


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.

like image 35
animuson Avatar answered Sep 26 '22 07:09

animuson