Send Mail using mail function in PHP

Submitted by:Jhon Smith

Date added:04 June, 2012


The mail() function allows you to send emails directly from a script.

Tags: mail function

Code Snippet:

$to = '';
$subject = 'Test Email';
$body = 'Body of your message here. You can use HTML tags also, e.g. <br><b>Bold</b>';
$headers = 'From: John Smith'."\r\n";
$headers .= 'Reply-To:'."\r\n";
$headers .= 'Return-Path:'."\r\n";
$headers .= 'X-Mailer: PHP5'."\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
mail($to, $subject, $body, $headers);