Posted By

apphp-snippets on 02/18/13


Tagged

php mail send


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ekarakas


Send Mail using mail function in PHP


 / Published in: PHP
 

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

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.

  1. <?php
  2. $to = '[email protected]';
  3. $subject = 'Test Email';
  4. $body = 'Body of your message here. You can use HTML tags also, e.g. <br><b>Bold</b>';
  5. $headers = 'From: John Smith'."\r\n";
  6. $headers .= 'Reply-To: [email protected]'."\r\n";
  7. $headers .= 'Return-Path: [email protected]'."\r\n";
  8. $headers .= 'X-Mailer: PHP5'."\n";
  9. $headers .= 'MIME-Version: 1.0'."\n";
  10. $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
  11. mail($to, $subject, $body, $headers);
  12. ?>

Report this snippet  

You need to login to post a comment.