Send Mail using mail function in PHP

/ Published in: PHP
Save to your folder(s)

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 site.

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


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.