For the most part, sending emails using PHP is one of the simplest things one could possibly do, using the mail() function. We usually just use a rudimentary script which can easily be ported around and used where ever it calls for, with minimal amount of hacking.
However, today an issue arose and caused quite some confusion. For some reason, for certain hosting providers, if you try sending an email using an address that doesn’t exist (in the From part of the header), it will discard the whole From: section and use something a lot uglier.
$header = 'From: Dude <[email protected]>'
All of that information above would be simply be ignored and replaced! The solution is to create the email address so that it does exist and it should be perfectly fine. This seems so obvious but you may not know initially, as we didn’t, that the email does actually need to exist.
I’m not sure if this is intentional or accidental on hosting provider’s part and I can see the benefits from an anti-spammer point of view. However, this is easily forgotten since this behaviour seems quite sporadic from host to host. To be honest, there probably are many other hosting providers that do this so when in doubt: create the email address.