Re: Working with overly aggressive anti-spam measures
| From: | Richard Lynch | Date: | Tue, 10 Oct 2006 19:01:35 +0000 |
| Subject: | Re: Working with overly aggressive anti-spam measures | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-242924@lists.php.net to get a copy of this message | ||
On Mon, October 9, 2006 8:55 pm, Dave M G wrote:
> If possible, can anyone help me with creating the PHP code that will
> make an email as legitimate as it can be? I know I can't totally
> prevent
> my email from being marked as spam (after all, if it were possible,
> all
> the spammers would do it). But as much as I can prevent anti-spam
> measures getting a false positive when testing my email, the better.
Get the problem users to send you valid email that gets through,
headers and all, and compare yours to theirs. :-)
> Here is the PHP code I currently use (trimmed for clarity):
>
> while ( $member = mysql_fetch_row($mysqlResult) )
> {
> $subscriber = $member[0];
> $email = $member[1];
> $subject = "Report for " . date('l jS F Y');
> $mailContent = "This is an email to " . $subscriber . " at " . $email
> . ".";
> $fromAddress = "info@mysite.com"
> mail($email, $subject, $mailContent, $fromAddress);
$fromAddress, by itself, is not a valid header line. That right there
is going to choke many mail agents, before they even try to look at it
for spam content.
$headers = "From: $fromAddress\r\n";
$headers .= "Reply-to: $fromAddress\r\n";
$extra = "-f$fromAddress";
mail($email, $subject, $mailContent, $headers, $extra);
$extra requires PHP 5 (4.x?) and that your mail config "trusts" the
Apache user to forge emails. It may not be possible in your setup.
> }
>
>
> And here is what the headers for an email from that code looks like:
>
> -Account-Key: account5
Hopefully this had an "X" in the front of it...???
> X-UIDL: UID497-1152485402
> X-Mozilla-Status: 0001
> X-Mozilla-Status2: 00000000
> Return-path: <nobody@server.myhostingservice.com>
This is set by $extra.
If your server won't let you change it, then there is little you can
do other than re-configure sendmail, switch hosts, and/or turn off
safe_mode -- all of which are outside the purvue of PHP and this list.
(Well, okay, safe_mode on/off is within our realm. Turn it off.)
> Envelope-to: info@mysite.com
> Delivery-date: Sun, 03 Sep 2006 14:22:42 -0700
> Received: from nobody by server.myhostingservice.com with local (Exim
> 4.52)
> id 1GJzQQ-0005pA-Mz
> for info@mysite.com; Sun, 03 Sep 2006 14:22:42 -0700
> To: member@subscriber.com
> Subject: Report for Monday 4th September 2006
> From: info@mysite.com
I'm AMAZED PHP and/or your MTA got this From: like this, when you
didn't do it right above...
> Message-Id: <E1GJzQQ-0005pA-Mz@server.myhostingservice.com>
> Date: Sun, 03 Sep 2006 14:22:42 -0700
>
> Which parts are key to change, and how?
You're actually very close to a valid email, mainly because you've
kept it so simple...
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?