• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

[PHP] Set Mail Return path question

ckevin

New Member
I have written a small script to send mail through Apache Web Server using sendmail. However, here is the email header of my message:

Return-Path: <apache@myname.com>
Received: from ns.myname.com (root@localhost)
by myname.com (8.11.6/8.11.6) with ESMTP id 18FGA1115234
for <email@email.com>; Sun, 15 Sep 2002 12:10:56 -0400
X-ClientAddr: 1.2.3.4

How can I write the PHP command so that the return path is the same as the email address of my "FROM" field rather than "apache@myname.com"? I don't want my hosting company to receive those return mail.

Thanks!
 
You can add

Return-Path: <email@domain.com>

to the headers. Here's some example code:
PHP:
$recipient = "recipient@domain.com";
$subject = "Email Subject";
$message = "This is the email message\n";
$headers = "From: John Smith <jsmith@domain.com>\n" .
           "X-Sender: <jsmith@domain.com>\n" .
           "X-Mailer: PHP\n" .
           "Return-Path: <jsmith@domain.com>\n";
mail($recipient, $subject, $message, $headers);
Richard
 
Richard, thanks for your help, but since the server has specific sendmail config, it won't work either, maybe I have to contact my host to change the sendmail config.

Thanks!
 
Back
Top