Skip to content

Instantly share code, notes, and snippets.

@clouddueling
Created August 20, 2013 18:53
Show Gist options
  • Select an option

  • Save clouddueling/6285635 to your computer and use it in GitHub Desktop.

Select an option

Save clouddueling/6285635 to your computer and use it in GitHub Desktop.
$chunks = array_chunk($mailgun_emails, 1000);
foreach ($chunks as $chunk) {
$emails = implode($chunk, ",");
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'api:frommyaccount');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v2/email.clouddueling.com/messages');
curl_setopt($ch,
CURLOPT_POSTFIELDS,
array(
'from' => 'info@clouddueling.com',
'to' => $emails,
'subject' => $queue->email->subject,
'text' => $queue->email->body . '<br><br> If you wish to unsubscribe, click http://mailgun/unsubscribe/%recipient.id%'
)
);
$result = curl_exec($ch);
curl_close($ch);
Log::mailgun($result);
Message::to($admin_email)
->from('admin@clouddueling.com')
->subject("Emailblast report")
->body("
INFO:
Account: {$account->name}<br>
Queue Id: {$queue->id}<br>
Order Id: {$queue->order_id}<br>
<br>
<br>
RESPONSE:<br>
{$result}<br>
<br>
<br>
EMAIL:</br>
{$queue->email->subject}<br>
<br>
{$queue->email->body}<br>
")
->html(true)
->send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment