Home Forums WordPress Plugins Mailgun Bulk Mailer Error Reply To: Mailgun Bulk Mailer Error

#29869
MM
Participant

To confirm. I have tested the API as they have suggested and it works well.

[code]
add_shortcode( ‘test_mailgun_api’, function(){
$apiKey = ‘f51eXXXXXXXXXXXXXXXXXXXX-d1a07e51-b785537c’;
$domain = ‘mg.domain.org’;
$from = ‘Excited User <[email protected]>’;
$to = ‘[email protected]’;
$to2 = ‘[email protected]’;
$subject = ‘Hello’;
$text = ‘Testing some Mailgun awesomeness!’;

$url = “https://api.mailgun.net/v3/$domain/messages&#8221;;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, ‘api:’ . $apiKey);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
‘from’ => $from,
‘to’ => $to,
‘to’ => $to2,
‘subject’ => $subject,
‘text’ => $text,
]);

$result = curl_exec($ch);
ob_start();
if (curl_errno($ch)) {
echo ‘Error:’ . curl_error($ch);
} else {
echo ‘Mail sent successfully’;
}

curl_close($ch);
return ob_get_clean();
});
[/code]