There's basically four parts used when an e-mail transaction happens.
The first part is the
HELO or
EHLO which is just an introduction that the sending server issues to the receiving server.
The next part is the
MAIL FROM address. This is the envelope sender.
The next part is the
MAIL TO address. This is who the address is being sent to. Also called the envelope-to.
The final part is the
DATA part, where headers and the message itself is constructed.
Using the PHP mail() function, it accepts 5 parameters. (
http://us.php.net/manual/en/function.mail.php)
The first parameter, the
to address is basically setting the
MAIL TO address.
The second and third parameters set the subject and message parts of the message. The subject is part of the header information so it is given after the
DATA part. The message is also given after the
DATA part.
The fourth parameter just sets any additional headers, which again are given after the
DATA part.
As you can see no envelope sender (MAIL FROM) address has been given yet. This can usually be defined with the fifth parameter, depending on what MTA you are using. Since all cPanel servers use exim as its MTA, you can define an envelope-sender for a message with:
"-fanother@address.com"
where
another@address.com is the defined envelope-sender.
The envelope sender is the e-mail address that bounce messages will go to. If you send a message out through a PHP script, and the mail server is unable to deliver that message to the intended recipient, then it will bounce back to this envelope sender. Mail servers themselves do not see anything that are in the headers, header information is generally only viewed by the e-mail client after the user receives the message.
As far as a receiving server is concerned it will see that a message was sent to the
envelope-to from
envelope-sender. So even if you set a From header using the fourth parameter of the PHP mail() function, the actual mail server is not going to know this value.