|
Posted by Gordon Burditt on 10/04/00 11:50
>My habitual use of mail() is causing me some grief. I am having
>slightly different results depending on the server I use but the gist
>is that mail() is returning 1, and I can send mail to yahoo.com,
>gmail.com, and hotmail.com no problem. 100% success.
Directly putting values from $_POST[] into email headers without
checking them for the absence of carriage return or linefeed
characters WILL get you listed as a spammer because your page WILL
be abused by spammers. (applies to your FULL HEADERS, FULL HEADERS
PLUS, and I don't see the 4th way). If you see carriage returns
or linefields in any fields to be put in headers, you should not
send mail and tell the spammer to fuck off (but don't be so polite
about it).
You can expect that some servers will reject your message as SPAM
because:
- There is no From: line.
- The address on the From: line is invalid.
- The address on the From: line is not allowed to send mail from
anyplace but specific servers (SPF) and the recipient server is
enforcing it.
- You aren't on their whitelist.
- Some spammer abused a script on another site hosted by the same
web provider as you did 6 years ago, and you have the same IP address.
Gordon L. Burditt
>Here are four ways I have tried this:
>
>// NO HEADERS
>$to = 'someone@gmail.com';
>$subject = "Inquiry from some.com";
>$msg = 'whatever';
>$result = mail($to, $subject, $msg);
>
>// FULL HEADERS
>$to = 'someone@gmail.com';
>$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
>$headers = "From: $_POST[name] <$_POST[email]>\r\n";
>$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
>$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
>$headers .= "Message-ID: <" . date("YdmHis") .
>".TheSystem@".$_SERVER['SERVER_NAME'].">" . "\r\n";
>$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
>$result = mail($to, $subject, $msg, $headers);
>
>// FULL HEADERS PLUS -f FLAG to set the envelope sender address
>$to = 'someone@gmail.com';
>$subject = "Inquiry from ENLA.com: $_POST[name] $_POST[company]";
>$headers = "From: $_POST[name] <$_POST[email]>\r\n";
>$headers .= "Reply-to: $_POST[name] <$_POST[email]>\r\n";
>$headers .= "Return-Path: $_POST[name] <$_POST[email]>\r\n";
>$headers .= "Message-ID: <" . date("YdmHis") .
>".TheSystem@".$_SERVER['SERVER_NAME'].">" . "\r\n";
>$headers .= "X-Mailer: PHP v". phpversion() . "\r\n";
>$result = mail($to, $subject, $msg, $headers,
>'-fwebmaster@mysite.com');
>
>
>I have also played around with setting all the headers to good
>addresses at my site to see any bounces from the SMTP server.
Navigation:
[Reply to this message]
|