PHP - Email Headers

by Dinesh 2014-10-30 14:22:51

Headers are the parts seen at the top of emails. Typically :
To :    A comma seperated list of recipient emails.
From :    The senders email address.
Reply-To :    The email address where replies should be sent to.
Return-Path :    Kinda the same thing as the Reply-To. Some email clients require this, others create a default.
Subject :    Subject of the email.
CC :    Carbon Copy. A comma seperated list of more recipients that will be seen by all other recipients.
BCC :    Blind Carbon Copy. A comma seperated list of more recipients that will not be seen by any other recipients.
 
<?php
$to = "toaddress@hiox.com";
$subject = "Email Subject.";
$message = "Email Message";

$headers = "From: fromaddress@hiox.com
";
$headers .= "Reply-To: fromaddress2@hiox.com
";
$headers .= "Return-Path: fromaddress@hiox.com
";
$headers .= "CC: sombodyelse@hiox.com
";
$headers .= "BCC: hidden@hiox.com
";

if ( mail($to,$subject,$message,$headers) ) {
   echo "The email has been sent!";
   } else {
   echo "The email has failed!";
   }
?> 

Tagged in:

673
like
0
dislike
0
mail
flag

You must LOGIN to add comments