【发布时间】:2013-08-06 12:05:15
【问题描述】:
我正在使用 sendgrid 发送邮件。大约有 20 个邮件模板。
我在 sendgrid 应用的设置中设置了退订模板“订阅跟踪”。
我的要求是不同邮件模板的退订链接文本不同。
目前,sendgrid 应用程序“订阅跟踪”中设置的只有一个静态unsubscribe link。
谁能帮助我如何在我的user_mailer 类中动态设置退订链接。
我点击了这个链接To give unsubscribe link in the mail using sendgrid XSMTPAPI header。但我不知道如何在 ruby 中实现它。
以下是我在user_mailer class 中尝试过的代码。
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
【问题讨论】: