Managing user opt-in with Mailgun - email

I have an app which sends a daily reminder message. If a user forgets to log in on certain days, it will send an email reminder. I want users to be able to unsubscribe to this reminder by clicking a link on the email. There may also be different kinds of subscription. For example, a user might not want daily emails, but they may want password reset, or blog emails.
Mailgun has an unsubscribe feature. While this allows some control with tags, this seems to lack a resubscription option. They also have a mailing list, but that also seems more for blasting emails rather than opting in to notifications.
One option is to connect the email to my database. So that when the user clicks an unsubscribe link, it will flip a flag in my database such that the user isn't contacted regarding this email. But I can't find a way to do this, that doesn't involve giving the user an API link on the emails.
What are some options I can do to solve this?

You probably would be able to accomplish this using Mailgun mailing lists (but I wouldn't for reasons below). You'd have to maintain a list for each type of email that you want to send to users. So when you add/delete users from your system you'll have to use the API or control panel to add/remove from each of the lists. Mailgun can generate a unique unsubscribe url for each of the lists so that when the user hits unsubscribe from the email it will flag the email as unsubscribed for that one list.
From Mailgun docs:
For managing unsubscribes in Mailing Lists, you can use
%mailing_list_unsubscribe_url%. We will generate the unique link to
unsubscribe from the mailing list. Once a recipient clicks on the
unsubscribe link, we mark the recipient as “unsubscribed” from this
list and they won’t get any further emails addressed to this list.
Mailing lists should work unless I don't understand your requirement.
From my point of view I'd just prefer to handle this inside my own system. Otherwise you have to maintain your application's user records and then a separate mailgun list for each email type. In multiple applications I have user email preferences stored in the db. The user (or customer admin login) can adjust preferences through the UI or in some cases by hitting unsubscribe link in an email which links to a web page (part of my app) "You have now unsubscribed to daily emails" -- the page sets the user as unsubscribed in my app DB.
Its extra work but the advantages to handling this in your app is:
You've only got one user DB (list) to maintain
List membership is easier to modify by the app user or app user account manager
It doesn't tie you as tightly to Mailgun -- in case you decide to
choose another provider
More on Mailgun Mailing lists:
https://documentation.mailgun.com/en/latest/user_manual.html#mailing-lists

Related

SendGrid - How to hide the "View Opt Out Preferences" button from Opt-Out Preferences page

We only enable unsubscribe links for all the marketing emails.(we have unsubscribe groups for that) So we don't provide unsubscribe links for other types of email, for example, a payment request email.
However, we discovered that on the Preferences page, users can still choose to Opt-Out of all Emails (global unsubscribe) thus they will no longer receive any email from us including the payment request. So wondering how could I disable this "View Opt Out Preferences" button so that users can only Opt-out one single group?
Edit Sep 20:
there is no such setting for custom unsubscribe link. Offical docu is out of date.
https://docs.sendgrid.com/ui/sending-email/create-and-manage-unsubscribe-groups#using-a-custom-unsubscribe-link
Twilio SendGrid developer evangelist here.
Sorry it's taken me a while to get to this. I've been chasing down what can be done here. There are a few options:
Subusers
If you are on a Pro account or higher, you can set up subusers within your account. The recommendation is to set up a subuser for your marketing emails and a different subuser for your transactional emails. That way unsubscribes from the marketing list won't affect the transactional email side of things. You can read about setting up subuser accounts here.
Create your own unsubscribe page
Rather than using the SendGrid provided unsubscribe page, that allows users to get to the "Opt out of all emails" button, you can create your own unsubscribe page. You can add a custom unsubscribe link to your emails. You can then use the API to add the email address to one of your unsubscribe groups.
Bypass suppressions
You can set the bypass_list_management filter to true when sending your mail to ignore all unsubscribe groups/suppressions. This seems like a last resort sort of fix, rather than something you should use for all transactional emails. The docs are fairly strongly worded on this:
It is important to respect unsubscribes, and these filters should be used only when it is absolutely necessary to deliver a message to recipients who have unsubscribed from your emails. For example, you may use these filters to deliver messages that you are legally required to send to all recipients or important security messages like a password reset.
Check out more on bypass list management.

How to use unsubscribe info for transactional and marketing emails?

Several vendors (SendGrid, MailChimp, SendInBlue) have "transactional" emails (sent via an external program relayed through the vendor) and "marketing" emails (managed in the vendor app through HTML templates). The vendors also have unsubscribe management and build up lists of people who have unsubscribed.
How do you use the unsubscribe information in the transactional mail side? If you try to send to X and they've unsubscribed, does it just drop the email sent to X? If not, do you have to check unsubscribe information in your own app before generating a transactional email?
What are best practices in managing this subscribe information across transactional and marketing applications? I have been searching the web, and I just find guides on how to set up the unsubscribe links (sendgrid, mailchimp, sendinblue) , but not how to use the information properly on the transactional side.
For SendGrid, if someone clicks on a global unsubscribe link, then future sends through the SendGrid transactional email API will drop it. You can see the Drop in the "Activity Feed" after the unsubscribe:
The unsubscribe list can be edited manually (to either add or delete names) through a web UI or an API.
There are also unsubscribe groups if you don't want one global unsubscribe list.
I still don't know the easiest way to integrate two systems, though. Presumably a scheduled job to copy from one system to another.

Secure way to undo an Opt-Out

Our WebApp allows members to send emails to other members and non-members for collaboration. Because I don't want to spam anyone, each mail to a non-member contains a link to opt-out from further mails. (Members can manage their mail preferences from within the app).
I wanted to respect the opt-out request without storing personally identifiable information such as the email address in our system, which is why I went for a hash-based implementation. Before a email is sent, the recipient is checked agains the opt-out list.
My opt-out table consist of the hash of the email address and an undo token:
hash(lowercase($email)), hash($undo_token)
The undo token is sent to the user along with the confirmation of the opt-out, should they change their mind. This token is required to remove an entry from the opt-out table.
However, people seem to delete those mails and we have received several requests that they want back in.
What is a secure, hard to abuse and automated way to undo an opt-out?
The solution should not allow a person to opt-in someone else. I also don't feel like sending emails to an address that is in my opt-out list without being sure it's them.
I am looking especially for links/references to credible and/or official sources. Thank you.
I'm sorry, I don't have any credible sources for you but this is just my thought. I have seen some unsubscription links look like http://some-email-service.com?action=OptOut&secretToken=3648789036219699210blahblahblah. They use something like action=OptOut passed as a GET parameter. If you too are using some similar approach to unsubscribe the user, why don't you just use action=UndoOptOut to reverse the action? Moreover, if the OptOut confirmation email that you send is deleted by the user, then there is no other way to undo it other than the user explicitly subscribing again.

How to add new email addresses from google form (sheets) to googlegroups email list?

I have a google form on my site that collects user info, including email addresses.
I have already created a script that sends a welcome email.
Now I need to be able to create an email list from that list of emails.
The resulting email list will be receiving triggers from IFTTT to send an email with particular triggers.
How do I get the email addresses from the form results (google sheets) to the mailing list (currently in googlegroups)?
The email list should be able to be triggered with a single address (something#googlegroups.com) because that's all IFTTT will allow.
(I'm working on a test process for a tech company. While we refine details of the app's function, which I am not building, we also want to test the real-world end of the process, and make it as simple and user-friendly as possible.)

Mailchimp? Mandrill? or both?

I am a bit confused with Mailchimp and Mandrill, what I need to do seems to need both, let me explain:
A social network needs to send at 1am everyday a notification email to their users that have not logged in during the last 24 hours. Emails have to be personalised.
On the top of that, there are different campaigns for different list of users.
My first thought is to use the mandrill API, but I need to be able to see who unsubscribe from what campaign (a user might want to unsubscribe to one campaign but stay subscribed on another one). I cannot seem to find something that fits the bill with Mandrill... Subaccount? Tags?
Thanks!
I'm not 100% sure this will answer the question, but let me try:
Mandrill actually belongs to MailChimp, and was created for interfacing with it. You can use the "mandrill-api" gem - https://mandrillapp.com/api/docs/ - to interface with many of the Mandrill and MailChimp features to do the things you wanted.
A lot of times if you are attempting to do so, and run into errors such as "XXXX not found", you have to send it FROM MailChimp TO Mandrill. For instance, when you create a template in MailChimp, click the dropdown menu next to the template, and click "Send to Mandrill". You should be good from there.
Other than that, I wish you luck. While the mandrill-api gem can do everything, it has absolutely abysmal documentation. There are multiple third-party gems that provide similar functions (mandrill-rails is a popular one) that you might have better luck with, but I have not used them myself.
Notifications = Mandrill = 1:1 emails
Campaigns = MailChimp = 1:many emails
Typically, notifications are 1:1 emails - your system sends a single user an email as a result of some trigger within the system. The trigger might match multiple users at the same time, but emails are sent to them each individually - probably via a loop in your code. Mandrill supports templates to personalise these emails if required.
Campaigns are sent to mailing list members in bulk, where the same (personalised) email is sent to multiple users at the same time. This is either triggered by hand (you manually create and send a campaign) or is based on a scheduled trigger (eg autoresponders or scheduled campaign mailing).
Notifications are generally system-related emails and while you do have the technical ability to let users unsubscribe from them in Mandrill, typically I would consider that a configuration option you'd give them in their personal control panel on your site.
Campaigns are something you MUST allow users to unsubscribe from to comply with anti-spam laws, so will contain unsubscribe links in the footer of every email.