Last active
October 7, 2016 03:26
-
-
Save paoga87/73f07482a9df5485c36738a6be2ea4b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Using PHP's mail() function--> | |
<?php | |
$to = '[email protected]'; | |
$subject = 'Subject line goes here'; | |
$message = 'Hi, this is me!'; | |
$headers = 'From: [email protected]' . "\r\n" . | |
'Reply-To: [email protected]' . "\r\n" . | |
'X-Mailer: PHP/' . phpversion(); | |
mail($to, $subject, $message, $headers); | |
?> | |
<!-- Using cur with Sendgrid --> | |
<?php | |
$url = 'https://api.sendgrid.com/'; | |
$user = 'USERNAME'; | |
$pass = 'PASSWORD'; | |
$params = array( | |
'api_user' => $user, | |
'api_key' => $pass, | |
'to' => '[email protected]', | |
'subject' => 'testing from curl', | |
'html' => 'testing body', | |
'text' => 'testing body', | |
'from' => '[email protected]', | |
); | |
$request = $url.'api/mail.send.json'; | |
// Generate curl request | |
$session = curl_init($request); | |
// Tell curl to use HTTP POST | |
curl_setopt ($session, CURLOPT_POST, true); | |
// Tell curl that this is the body of the POST | |
curl_setopt ($session, CURLOPT_POSTFIELDS, $params); | |
// Tell curl not to return headers, but do return the response | |
curl_setopt($session, CURLOPT_HEADER, false); | |
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); | |
// obtain response | |
$response = curl_exec($session); | |
curl_close($session); | |
// print everything out | |
print_r($response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment