There was a problem loading the comments.

PHP email - From header

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

Your PHP mail() script emails always show "From: cPanel-username@servername".

You can change that by adding the following code:

$headers = 'From: user@yourdomain.com' . "\r\n" .
'Reply-To: user@yourdomain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

Then just add $headers to the mail function. See the related article for a complete script.

You can also add CC and BCC to your emails by adding this code:

$headers = 'From: user@yourdomain.com' . "\r\n" .
'Cc: user@hisdomain.com' . "\r\n" .
'Bcc: user@herdomain.com' . "\r\n" .
'Reply-To: user2@yourdomain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

IMPORTANT - You must add the header variable as the 4th attribute in the mail() function. EXAMPLE - mail($to, $subject, $message, $headers);


Share via
Did you find this article useful?  

Related Articles


Comments

Add Comment

Replying to  

CAPTCHA
© Osirion System Technologies