This is a relatively simple question that may just not have a solution.
Is it possible to set the message To: header and send the email in PHP? Note that message To: is different from the envelope To: header. The latter actually determines where the email is routed, and the former just determines what it shown in the recipient’s email program.
Background: I’m setting up a little disposable email service for myself, so I’m receiving emails with a PHP script, modifying a few headers, and re-sending it to my real email address. I’d like the original recipient email address (the disposable email address) to still show up on the message when I receive it in my real email box (for client-side filtering rules, etc.).
Is this possible? I’ve been able to modify every other type of header, but this one has me stuck.
Thanks for everyone’s help! I found an excellent solution, so I thought I’d share.
I ended up just extending CodeIgniter’s email class to set a To header (I’m heretofore going to start calling it a vanity header since it’s all looks and no substance) and sending via SMTP. If you want to see a simple example of what I did, extend the Email class with your own MY_Email.php file (see the section on Extending Native Libraries in the User Guide) and copy over the _build_headers() function from the Email class.
Then add your own header on the line immediately below the Mime-Version line, like so:
Then just send a regular email to one of your own email addresses. You’ll notice that even though the email arrives at your address, it appears to be addressed to person@example.com.
Boom.
If you’d like to actually use the full MY_Email.php file I created to add a “Vanity To” option to your own CodeIgniter project, see this gist.