Skip to content

Instantly share code, notes, and snippets.

@slav123 slav123/mailgun.php
Created Mar 11, 2016

Embed
What would you like to do?
send mail via mailgun no external libraries
<?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
You can’t perform that action at this time.