Skip to content

Instantly share code, notes, and snippets.

@sebmih
Created July 17, 2013 10:16
Show Gist options
  • Save sebmih/6019374 to your computer and use it in GitHub Desktop.
Save sebmih/6019374 to your computer and use it in GitHub Desktop.
PHP's mail() function with SendGrid' SMTPAPI
<?php
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: Sender Name <sender@domain.com>";
$headers[] = "Bcc: JJ Chong <bcc@domain2.com>";
$headers[] = "Reply-To: Recipient Name <receiver@domain3.com>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
$headers[] = "X-SMTPAPI: {"category":"testing123"}";
mail($to, $subject, $email, implode("\r\n", $headers));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment