Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- # Instantiate the client.
- $mg = new Mailgun('key-043780ddd6aec45f3f9361bf79d69491');
- $domain = 'ppd-mail.net';
- $batchMsg = $mg->BatchMessage($domain);
- $batchMsg->setReplyToAddress(''.$this->campaign->data['sender_name'].' <'.$this->campaign->data['sender_email'].'>');
- $batchMsg->setFromAddress(''.$this->campaign->data['sender_name'].' <'.$this->campaign->data['sender_email'].'>');
- $batchMsg->setSubject($this->campaign->data['subject']);
- $batchMsg->setHtmlBody(file_get_contents($this->campaign->data['payload']));
- $batchMsg->addCustomHeader('ppd_campaign_id', $this->campaign->id);
- $batchMsg->addCampaignId($this->campaign->id);
- foreach($this->campaign->contacts() as $contact):
- $batchMsg->addToRecipient($contact->email, ['ppd_recipient_id' => $contact->id, 'ppd_campaign_id' => $this->campaign->id, 'ppd_list_id' => $contact->list_id]);
- endforeach;
- // Finish our send
- $batchMsg->finalize();
- $this->campaign->status = 3;
- $this->campaign->delivered_at = Carbon::now();
- $this->campaign->save();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement