views:

24

answers:

1

I want to make an email forwarder similar to cPanel's, where I have a database of email addresses, and where they should forward to, and I set a catch-all to pipe to my script.

I have completed this script, however, I would like to make the "To:" field in the header show the address it was sent to, rather than who is was being delivered to. For example, the email was sent to [email protected], and the script forwards it to [email protected]. How can I make PHP send mail to [email protected], but still show [email protected] in the headers, like cPanel does?

A: 

You can use the headers of the mail function:

$to = '[email protected]';
$subject = 'Testing';
$message = 'This is a test';
$headers .= 'To: User001 <[email protected]>, User002 <[email protected]>' . "\r\n";
$headers .= 'From: My Email Script <[email protected]>' . "\r\n";
mail($to, $subject, $message, $headers);
PIM
Dosn't work. That makes them both show in the To headers (2 To headers are in the email)
ari_aaron