Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

PHP mail keeps sending from "nobody@<server_hostname>", resulting emails to fail anti-spam checks

Any idea how I can stop PHP from emailing from "nobody@<server_hostname>" without enabling PHPsuExec?

I've tried the following but to no avail:

<?
    ini_set("sendmail_from", "noreply@<domain>");
    $strHeaders .= "Return-Path: noreply@<domain>\n\r";
?>

Any help on this topic would be greatly appreciated. Thanks in advance!
0
DReade83
Asked:
DReade83
1 Solution
 
ncooCommented:
If you set the from email in the mail() t

mail( "to@email", "Subject","body", "From: from@email");

http://php.net/mail
0
 
DReade83Author Commented:
Sorry, meant to say, I've already done that. Although I've found setting the "-f" parameter sets the Return-Path.

I'll give that a go instead. Thanks anyway.
0
 
jasonsbytesCommented:
This works for me:

                       $org_var = "Flight Exams";
                        $domain_user = "flightexams@flightexams.com";
                        $emailfrom = "desouthard@hotmail.com";

                        $header  = "MIME-Version: 1.0\n";
                        $header .= "Content-type: text/html; charset=iso-8859-1\n";
                        $header .= "Content-Transfer-encoding: 8bit\n";
                        $header .= "From: ".$org_var." <".$emailfrom.">\n";
                        $header .= "Message-ID: <".md5(uniqid(time()))."@flightexams.com>\n";
                        $header .= "Return-Path: ".$domain_user."\n";
                        $header .= "X-Sender: ".$domain_user."\n";
                        $header .= "X-AntiAbuse: This is a solicited email from - ".$org_var." for an appointment to take an FAA pilot exam.\n";
                        $header .= "X-AntiAbuse: Servername - FlightExams.com\n";
                        $header .= "X-AntiAbuse: User - ".$domain_user."\n";

mail("somebody@hotmail.com", "Subject", $body, $header);
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
rbartzCommented:
You cannot set Return-Path with the other headers if you are using the PHP mail() command as it uses sendmail.  Do it this way:

$to = 'joe@blow.com';
$subject = 'Lower Spam Scores';
$body = 'Blah, blah, blah';
$headers = 'From: webmaster@example.com' . '\r\n' .
   'Reply-To: webmaster@example.com' . '\r\n' .
   'X-Mailer: PHP/' . phpversion();
$return_path = 'noreply@example.com' ;

mail($to, $subject, $body, $header, '-f $return_path');

Cheers,

RDB


0
 
rbartzCommented:
Nuts...

Made a mistake in the mail() command in my post above!  

Should be HEADERS, not header as in:

mail($to, $subject, $body, $headers, '-f $return_path');

RDB
0
 
DReade83Author Commented:
It's OK, '-f' sorted it at the time. Thanks anyway.
0
 
rbartzCommented:
Sorry,

I saw the question was still open and thought you did not have an answer.  You should close the question, you can ask for your points back.  It should not be a problem as you found your own solution!

Cheers!  Happy New Year!

RDB
0
 
DReade83Author Commented:
No probs, cheers mate. Happy 2008 to you too. :)
0
 
modus_operandiCommented:
Closed, 500 points refunded.
modus_operandi
EE Moderator
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now