Reputation: 186
First of all I know that Mandrill has it's own way of coping with unsubscribe, which is "Adding a link with the unsubscribe merge tag" . But it stores the unsubscribed users on the account and makes rejection if sent newsletters and announcements to that recipient.
So I have this code part which is sent to each and every recipient separately with foreach loop and sends every mail separately:
foreach($subscribers as $subscribersRow){
$to = $subscribersRow['usr_email'];
$message .= '<br/><br/><a href="'.site_url('unsubscribe').'/?email='.urlencode($to).'">Click here to unsubscribe.</a>';
However, Mandrill has a adventage in sending email similar to forwarding by using one line of code for the $to recipient:
'to' => array(array('email' => '[email protected]' ),array('email' => '[email protected]' ))
I want to use this advantage of Mandrill (2000 emails/day), delete the foreach and make Madrill server put the recipient's email in the $to place. That way this part of code will get default value, instead of unique and I will be able to use the second code-snippet. That way it won't reject the emails sent to unsubscribed(won't bother sending at all) and I'll mark it unsubscribed in my database. I use Codeigniter API to do the sending. Do you know how can I help Mandrill to help me with this thing. Thanks in advance
Upvotes: 0
Views: 2300
Reputation: 2736
Use a webhook to detect unsubscribes and have your webhook code mark them as unsubscribed in your database to prevent resends.
So you just send using Mandrill as normal and have Mandrill add its own unsubscribe link.
Next you set up a webhook which listens to unsubscribe events from users.
When the webhook is triggered it will call your webhook code, and your code will mark the user as unsubscribed in your database.
Upvotes: 1