PHP: Send an email. (simple)

Posted October 2nd, 2010


A simple example of how to send an email using PHP's build in mail() function.

<?php
function sendMail($from,$to,$subject,$body){
  $headers = "From: $from";
  $headers .= "Reply-To: $from";
  headers .= "Return-Path: $from";
  $headers .= "X-Mailer: PHP5\n";
  $headers .= 'MIME-Version: 1.0' . "\n";
  $headers .= 'Content-type: text/html; charset=utf-8' . "";
  @mail($to,$subject,$body,$headers);
}
?>