Send email with PHP script

So you want to send an email through a PHP script. Well that is dead simple (provided you have your smtp server setup correctly). See the code fragment below:

$to = "email@to.com";
$subject = "Your subject";
$message = "Your message";
$headers = "From: webmaster@from.com" . "\r\n" .
   "Reply-to: webmaster@from.com" . "\r\n" .
   "X-Mailer: PHP/" . phpversion();
mail($to, $subject, $message, $headers);

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *