Skip to content

Instantly share code, notes, and snippets.

@johnmorris
Created October 28, 2015 16:54
Show Gist options
  • Save johnmorris/3310cbb18ea6d104974a to your computer and use it in GitHub Desktop.
Save johnmorris/3310cbb18ea6d104974a to your computer and use it in GitHub Desktop.
How to send email with PHP
<?php
// Recipient
$to = 'RECIPIENT EMAIL ADDRESS';
// Subject
$subject = 'This is our test email';
// Message
$message = '<h1>Hi there.</h1><p>Thanks for testing!</p>';
// Headers
$headers = "From: The Sender Name <SENDER EMAIL ADDRESS>\r\n";
$headers .= "Reply-To: REPLY-TO EMAIL ADDRESS\r\n";
$headers .= "Content-type: text/html\r\n";
// Send email
mail($to, $subject, $message, $headers);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment