How to add Unsubscribe link in email sending to multiple users at once

2.1k views Asked by At

I am sending notification mails to all the registered users in the site with an Unsubscribe link. Currently I am lopping through all users in the db and sending mail to each user. For the Unsubscribe link i am adding the user email to differentiate between each users when they click the link. Everything except the Unsubscribe link is same in the email.

Is there any way to send mail to all users at once without looping and get the Unsubscribe link for each user different, so that i can differentiate between each user when they click the link

2

There are 2 answers

0
Eugen Rieck On BEST ANSWER

Simply said: No

Two emails can either be identical or not - if they have different links in them, they are not. There is no mechanism to send different emails to different users in one go.

0
AxeEffect On

If you use some email delivery service like SendGrid or PostageApp they offer this kind of functionality. On SendGrid they have the X-SMTPAPI Header with support for Substitutions -JSON text strings- (http://sendgrid.com/docs/API_Reference/SMTP_API), where each Substitution (a customised/dynamic piece of text) value corresponds to an email in the “To” section of the JSON string.

With this you can post once the email to the delivery service together with the receiver list and your customised fields -like names or unsubscribe links- and the delivery service will take care of merging and sending the emails to all the receivers.

This approach will save a lot of bandwidth and processing time the more you use it. If you don't send many emails these email delivery services offer limited free accounts.