Reputation: 806
Basically, I'm using sendgrid to send emails to subscribers, my email sending function looks like this and I'm using the nodejs API (documentation is here: https://github.com/sendgrid/sendgrid-nodejs):
var email = new sendgrid.Email();
email.addTo('[email protected]');
email.subject = "Send with templates app";
email.from = '[email protected]';
email.text = 'Hi there!';
email.html = '<h1>Hi there!</h1>';
// add filter settings one at a time
email.addFilter('templates', 'enable', 1);
email.addFilter('templates', 'template_id', '09c6ab89-9157-4710-8ca4-db7927c631d6');
// or set a filter using an object literal.
email.setFilters({
'templates': {
'settings': {
'enable': 1,
'template_id' : '09c6ab89-9157-4710-8ca4-db7927c631d6',
}
}
});
and i noticed that I could use the add to unsubscribe list api call provided by sendgrid but I'm just confused how to do it within my email, I believe I can create an button within my email that could be clicked but how would it work? Would an api call be created everytime the button is pressed and would the method be part of the email or can it be written in the code in my server?Heres the API call for unsubscribe: https://sendgrid.com/docs/API_Reference/Web_API/unsubscribes.html
Upvotes: 0
Views: 2755
Reputation: 9814
SendGrid will manage all of that for you. You can turn on Subscription Management in your SendGrid UI, at https://app.sendgrid.com/settings/tracking. You can also enable this on a per-message basis if you'd like, via the setFilters()
method. See more info.
Upvotes: 0