How do I change the PHP Mail() from address?

When using the PHP Mail() function you will find that the ‘from’ email address is often an unfriendly looking system email address sometimes even belonging to the root or system user, this can confuse your userbase as well as making it impossible for them to reply to any system messages that you send.

To make this change you first need to decide which email address you would like the from address to represent. This email address must exist on the server where your PHP Mail() function is being called, if the email address you choose does not exist, then your efforts will be wasted.

$result = mail(“to@address.com”, “subject”, “message”, “From: other@address.com\n”, “-fother@address.com”);

Make sure that the other@address.com exists on the server, if it does not, this will not work.

If you have any problems simply contact the Helpdesk for further assistance,

Was this helpful?

1 thought on “How do I change the PHP Mail() from address?”

  1. When viewing this my browser, Firefox, displayed the following information in your reply. In my browser the last inverted comma is shown as a single and it appears to have missed out possible closing bracket. I don’t have immediate need of this code but some of your other users may have found this to be a problem. regards john

    $result = mail(“to@address.com”, ”subject”, ”message”, ”From: other@address.com\n”, ”-fother@address.com”

Comments are closed.