Page 1 of 1

PHP PEAR Mail Marked As Spam?

Posted: Tue Dec 14, 2010 4:50 pm
by djlex1928
I cannot understand the problem here:

I've marked all my info as "***" this is correct in the original code.

Code: Select all

<?php
 require_once "Mail.php";
 
 $from = "***";
 $to = "***";
 $subject = "***";
 $body = "***";
 
 $host = "***";
 $username = "***";
 $password = "***";
 $replyto = '***';
 
 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject,
   'Reply-To' => $replyto,
   'MIME-Version' => '1.0',
   'Content-type' => 'text/html; charset=iso-8859-1');
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'auth' => false,
     'username' => $username,
     'password' => $password));
 
 $mail = $smtp->send($to, $headers, $body);
 
 if (PEAR::isError($mail)) {
   echo("<p>" . $mail->getMessage() . "</p>");
  } else {
   echo("<p>Message successfully sent!</p>");
  }
 ?>
I cannot understand why this is happening, mail sent using this method is moved to the Junk folder in Outlook, and I beleive in Hotmail too. Gmail works just fine, any others I'm not sure.

Something that might affect this is that it's being run from a local server at my place of work. All I want to do is confirm orders placed on our website, but it seems pointless if the emails are being marked as spam? Is there any way I can stop this happening?

Re: PHP PEAR Mail Marked As Spam?

Posted: Tue Dec 14, 2010 5:06 pm
by Jonah Bron
Spam filters often trigger when an email's From and Reply-To headers don't match the actual server it came from.

Re: PHP PEAR Mail Marked As Spam?

Posted: Tue Dec 14, 2010 8:42 pm
by califdon
In any case, it has nothing to do with your PHP code. Your question pertains to whatever the spam filter rules are in each email client.

Re: PHP PEAR Mail Marked As Spam?

Posted: Wed Dec 15, 2010 6:58 am
by internet-solution
Spam filter rules will also be affected by "reputation" of your mail / webserver. If you are on a shared server and some users send out spams from it, the server will end up in spam blacklists. A workaround might be to use external SMTP mail servers (your ISP / Gmail) for sending out mails.

Re: PHP PEAR Mail Marked As Spam?

Posted: Wed Dec 15, 2010 8:44 am
by djlex1928
I fixed it adding a couple things to the the headers, works perfect now.

Re: PHP PEAR Mail Marked As Spam?

Posted: Wed Dec 15, 2010 11:14 am
by Jonah Bron
For the sake of other people that experience this problem in the future, what did you change?