How to send e-mail using PHP

Published: Saturday, 4 June 2005
php mail

Use the mail() function.

You can see if your website supports it by testing with the following example:

<?
  $to = "tester@example.com";
  $from = "php@example.com";
  $subject = "test php mail function";
  $message = "this is a 2\n line message.";

  if ($from) {
    $headers .= "From: $from";
  }
  if (mail($to, $subject, $message, $headers)) {
    print "mail sent successfully to $to";
  }
  else {
    print "mail send failed!";
  }
?>