I am using sendgrid for sending mails. There are around 20 mail templates.
I have set unsubscribe template in the settings of sendgrid app "Subscription Tracking".
My requirement is different texts for unsubscribe link for different mail templates.
Currently, only one static unsubscribe link
as set in the sendgrid app "Subscription Tracking" is coming.
Can any one help me how to dynamically set the unsubscribe link in my user_mailer
class.
I followed this link To give unsubscribe link in the mail using sendgrid XSMTPAPI header. But I do not know how to implement it in ruby.
Below is the code what I have tried in my user_mailer class
yet.
def abuse_notification(post,current_user,eventid)
headers['X-SMTPAPI'] = '{"filters":{"subscriptiontrack":{"settings":{"enable":1,"text/html":"Unsubscribe <%Here%>","text/plain":"Unsubscribe Here: <% %>"}}}}'.to_json()
UserNotifier.smtp_settings.merge!({:user_name => "info@xxxx.example.com"})
@recipients = "test@xxx.example.com"
@from = "xxxx"
@subject = "Report Abuse Notification"
@sent_on = Time.now
@body[:user] = current_user
@body[:event] = post
end