Return to Snippet

Revision: 62359
at February 18, 2013 21:23 by apphp-snippets


Initial Code
<?php
$to = '[email protected]';
$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'."
";
$headers .= 'Reply-To: [email protected]'."
";
$headers .= 'Return-Path: [email protected]'."
";
$headers .= 'X-Mailer: PHP5'."\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1'."
";
mail($to, $subject, $body, $headers);
?>

Initial URL
http://www.apphp.com/index.php?snippet=php-send-mail-using-mail-function

Initial Description
The mail() function allows you to send emails directly from a script. Remember, that most of shared hosting providers require (for security reasons) to use the domain name of your hosting in "FROM" email, e.g. [email protected] for http://yourdomain.com site.

Initial Title
Send Mail using mail function in PHP

Initial Tags
php, mail

Initial Language
PHP