Skip to content

Instantly share code, notes, and snippets.

@luckyshot
Last active September 16, 2017 21:53
Show Gist options
  • Save luckyshot/6bc4482aa151bd4d09af to your computer and use it in GitHub Desktop.
Save luckyshot/6bc4482aa151bd4d09af to your computer and use it in GitHub Desktop.
HTML emails in PHP
<?php
$email = array(
'fromName' => 'Adam',
'fromEmail' => 'adam@example.com',
'toName' => 'Bob',
'toEmail' => 'bob@example.com',
//'cc' => 'charles@example.com',
'subject' => 'Website Change Request',
'body' => 'Hello,<br>Bye',
'headers' => "From: ".$email['fromName']." <".strip_tags( $email['fromEmail'] ).">\r\n".
"Reply-To: ".$email['fromName']." <".strip_tags( $email['fromEmail'] ).">\r\n".
//"CC: ".$email['cc']."\r\n".
"MIME-Version: 1.0\r\n".
"Content-Type: text/html; charset=utf-8\r\n",
);
echo mail( $email['to'], $email['subject'], $email['body'], $email['headers']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment