メールの送信に sendgrid を使用しています。約 20 のメール テンプレートがあります。
sendgrid アプリの「Subscription Tracking」の設定で、退会テンプレートを設定しました。
私の要件は、メール テンプレートごとに登録解除リンクのテキストが異なることです。
unsubscribe link
現在、 sendgrid アプリ「サブスクリプション トラッキング」で設定されている1 つの静的のみが来ています。
user_mailer
クラスで購読解除リンクを動的に設定する方法を教えてください。
このリンクをたどって、 sendgrid XSMTPAPI header を使用してメールで購読解除リンクを提供します。しかし、それをルビーで実装する方法がわかりません。
以下は、私が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