Created
March 11, 2016 10:36
-
-
Save slav123/197bee1c04be83f0f764 to your computer and use it in GitHub Desktop.
send mail via mailgun no external libraries
This file contains 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
<?php | |
function send_simple_message() { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); | |
curl_setopt($ch, CURLOPT_USERPWD, 'api:key-example'); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); | |
curl_setopt($ch, CURLOPT_URL, | |
'https://api.mailgun.net/v2/samples.mailgun.org/messages'); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, | |
array('from' => 'Dwight Schrute <dwight@example.com>', | |
'to' => 'Michael Scott <michael@example.com>', | |
'subject' => 'The Printer Caught Fire', | |
'text' => 'We have a problem.')); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
return $result; | |
} | |
echo send_simple_message(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment