4

Can any one please tell me how to add unsubscribe link in the mail which is send by modifying the header.I am using Sendgrid header XSMTPAPI, although I found a relevant header called subscription track in the filters, but couldn't figure out how to use it.

rampuriyaaa
  • 4,926
  • 10
  • 34
  • 41

1 Answers1

5

You would want to have an X-SMTPAPI header that looked something like this when broken out:

{ 
  filters: { 
    subscriptiontrack: { 
      settings: { 
        enable: 1,
        "text/html": "Unsubscribe <%Here%>", 
        "text/plain": "Unsubscribe Here: <% %>" 
      } 
    } 
  }
}

When you're sending the request, make sure you stringify the JSON for the header:

X-SMTPAPI: '{"filters":{"subscriptiontrack":{"settings":{"enable":1,"text/html":"Unsubscribe <%Here%>","text/plain":"Unsubscribe Here: <% %>"}}}}'

Also, as a side note, all of this can be found on the docs page for the X-SMTPAPI header:

Swift
  • 13,118
  • 5
  • 56
  • 80
  • can you help me in setting X-SMTPAPI in `ruby-on-rails`. I put a question related to this in http://stackoverflow.com/questions/18079692/how-to-dynamically-set-unsubscribe-link-in-sendgrid-using-ruby-on-rails – Krishna Rani Sahoo Aug 06 '13 at 12:36