私は宝石https://github.com/sendgrid/sendgrid-rubyを使用しています
SendGrid には、次のようなトランザクション メール テンプレートがあります。
<%body%>
Hello :name!, what's up
your number is :number.
This is the transactional footer
変数を渡す方法:number
、:name
??
ありがとう、
私は宝石https://github.com/sendgrid/sendgrid-rubyを使用しています
SendGrid には、次のようなトランザクション メール テンプレートがあります。
<%body%>
Hello :name!, what's up
your number is :number.
This is the transactional footer
変数を渡す方法:number
、:name
??
ありがとう、
テンプレートに関連する のセクションをREADME
確認してください。
メールを送信するユーザー モデルがあるとします。
# assuming some users
recipients = []
users.each do |user|
recipient = SendGrid::Recipient.new(user.email)
recipient.add_substitution('name', 'some name')
recipient.add_substitution('number', 1234)
recipients << recipient
end
# then initialize a template
template = SendGrid::Template.new('MY_TEMPLATE_ID')
# create the client
client = SendGrid::Client.new(api_user: my_user, api_key: my_key)
# set some defaults
mail_defaults = {
from: 'admin@email.com',
html: '<h1>I like email</h1>',
text: 'I like email',
subject: 'Email is great',
}
mailer = SendGrid::TemplateMailer.new(client, template, recipients)
# then mail the whole thing at once
mailer.mail(mail_defaults)