Bypass SendGrid's list management with sendMail
If you use SendGrid as the email service for your grails app then you probably saw a case where:
Some e-mails are too important to do normal list management checks, such as password resets or critical alerts. Enabling this filter will bypass the normal unsubscribe / bounce / spam report checks and queue the e-mail for delivery.
SendGrid has a nice feature that allows you to <a href="http://docs.sendgrid.com/documentation/apps/bypass-list-management/">bypass list management</a> by sending custom email headers. Here's how you do that in sendMail:
void testBlockedEmail() {
def emailHeaders = [:]
emailHeaders['X-SMTPAPI'] = new JSON(["filters":["bypass_list_management" : ["settings":["enable":1]]]])
mailService.sendMail {
headers emailHeaders
from 'email@company.com'
to 'recepient@gmail.com'
subject 'List management'
body 'Hello world!'
}
}
See <a href="http://docs.sendgrid.com/documentation/apps/bypass-list-management/">SendGrid documentation</a> for more.
Written by Andrei Taraschuk
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Groovy
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#