Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP Mailer to Junk Folder

ddtpmyra's Avatar
Familiar Sight
 
Join Date: Jun 2008
Location: CA
Posts: 222
#1: Jun 4 '09
Below is the scripts that triggered everytime users update the database and send a blast of emails to the user group. The problem is the email goes to JUNK folder and I wonder though I use the company STMP and company email.

Any idea how to this happened?
Expand|Select|Wrap|Line Numbers
  1. #email process starts here
  2. require("class.phpmailer.php");
  3. $mail = new PHPMailer();
  4. $mail->From     = "xxx@xxx.com";
  5. $mail->FromName = "adminr";
  6. $mail->Subject = "New Document";
  7. $mail->Host     = "xx.xx.x.x"; // SMTP server
  8. $mail->Mailer   = "smtp";
  9.  
  10. $query ="SELECT * FROM members" ;
  11.  
  12. $result=@MYSQL_QUERY($query);
  13. while ($row = mysql_fetch_array ($result)) {
  14.             // HTML body
  15. $body  = "Hello <font size=\"4\">" . $row["fname"] . "</font>, <p>";
  16. $body .= " <font size=\"4\"> A NEWdocument is now available for your review" . $row["fileid"] ."</font><p>";
  17. $body .= "Thank You, <br>";
  18. $body .= "Administrator";
  19.  
  20. / Plain text body (for mail clients that cannot read HTML)
  21. $text_body  = "Hello " . $row["fname"] . ", \n\n";
  22. $text_body .= "New document is now available for your review.\n \n";
  23. $text_body .= "Thank You, \n";
  24. $text_body .= "Administrator";
  25.  
  26. $mail->Body    = $body;
  27. $mail->AltBody = $text_body;
  28. $mail->AddAddress($row["email"], $row["fname"]);
  29.  
  30. if(!$mail->Send())
  31. echo "There has been a mail error sending to " . $row["email"] . "<br>";
  32. // Clear all addresses and attachments for next loop
  33. $mail->ClearAddresses();
  34. $mail->ClearAttachments();
  35. }
  36.  

code green's Avatar
Expert
 
Join Date: Mar 2007
Location: England
Posts: 1,083
#2: Jun 5 '09

re: PHP Mailer to Junk Folder


I think you'll find this is down to the filter settings on the receiving email application.
You cannot tamper with a receiver's email settings but you can try to beat the filter.

To avoid emails going to junk or being flagged as spam the content needs adjusting.
This is a fairly dynamic subject but just one word can condemn the email.
A study of this subject is recommended.

Another problem can be attachments. Try zipping them.
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,754
#3: Jun 5 '09

re: PHP Mailer to Junk Folder


I would also reconsider the subject of your mail. Try making it more... like an actual sentence.

Meaning; instead of "New document", try something like "There is a new document ready for you.".

And, also,it's best to use "\r\n" for line-breaks in emails.
dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,095
#4: Jun 5 '09

re: PHP Mailer to Junk Folder


It also has to do with the reputation of the sender's mail server/domain accounts.

I know hotmail junks it if the domain is new and doesn't have an SPF record.

DNSstuff.com use to have a good checking mechanism but that site is not free anymore. That's what I used to correct all the non-standard setting about my domain and mail records.

Also, make sure the email is structured (i.e. has headers, from address, etc).

After all this, then worry about words in your email or attachments.

Good luck,




Dan
Reply


Similar PHP bytes