I’m using PHP’s mail() function on a form to send an e-mail to an address that has an auto-respond. Unfortunately, since the e-mail is generated from a form, it tries to reply to http://www.domain.com@web.pas.earthlink.net, which doesn’t exist, and bounces back.
mail("info@domain.com", $email_subject, $email_message, $headers);
other info:
$email_from = "forms@domain.com";
$headers = "From: ".$email_from;
$headers .= "\nReply-To: ".$email_from;
$headers .= "\nReturn-Path: ".$email_from;
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
Is there any way to fix this? How can I set a proper return address?
edit: I should say that when the response arrives, the reply-to address IS set correctly to $email_from. Regardless, the auto-responder still tries sending it to http://www.domain.com@web.pas.earthlink.net.
The Return-Path is not like other mail headers. It’s a so called “envelope header”. Those are set by the MTA, not by fields in the header part of the actual mail. Most MTAs have a special flag for setting the Return-Path. In Postfix, Sendmail and Exim it’s the
fflag, so on those systems you can usually callmaillike this: