Forum Moderators: coopster

Message Too Old, No Replies

trouble setting mail() return path - defaults to apache?

         

blaketar

9:53 pm on Jul 30, 2007 (gmt 0)

10+ Year Member



I am having some difficulty in setting the Return-Path header in our mail() script. When I analyze the headers of a test message it always comes up as:

Return-Path: <apache@mydomain.com>

Here is the header setup in our mail() script. Domains and email addresses have been altered:

$headers = "From: Name <'mail@mail.com'>\n";
$headers .= "Reply-To: Name <'mail@mail.com'>\n";
$headers .= "Return-Path: Name <'mail@mail.com'>\n";
$headers .= "Message-ID: <".$now."TheSystem@".$_SERVER['SERVER_NAME'].">\n";
$headers .= "X-Mailer: PHP v".phpversion()";

Is it possibly a setting in php.ini that is restricting the mail function headers to be changed? Thanks!

RonPK

6:42 pm on Jul 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might try using the fifth parameter to mail, which passes info directly to sendmail.

mail($to, $subject, $message, $headers, '-fmyname@example.com');

Note that there is no whitespace between the -f flag and the email address.

An alternative would be to set the flag more permanently in php.ini:

sendmail_path = "/usr/sbin/sendmail -t -i -f myname@example.com"

blaketar

6:32 pm on Aug 3, 2007 (gmt 0)

10+ Year Member



Thanks, that worked great and accomplished the task exactly!

Does anyone have any insight or recommendations for using the mail() function with a form that emails other members on a site?

Example: Our email inquiry form allows a person to input his/her email address, a short question and then the system, using the mail() function sends the email to the recipients email address we have on file.

Do email providers like yahoo or hotmail look at these messages as spammy since mydomain.com/IP sent the email and it contains a different return too: email address, etc.?

RonPK

7:45 pm on Aug 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The best way to find out about Yahoo and Hotmail's spam policies is to get yourself an account and give it a try ;)

Some things that may help are no HTML in the mail, valid PTR in DNS, an SPF record, a name in the To: header, and of course no mentioning of private parts, casino's, stocks, credit, and so on.