1
votes

I've intergrated the sendgrid-ruby gem on my rails app and am trying to send an email I used to have sent via ActionMailer. I've used the example from sendgrid:

from = Email.new(email: '[email protected]', name: 'Test Sender')
to = Email.new(email: '[email protected]')
subject = 'This is a sendgrid test email'
content = Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby')
mail = Mail.new(from, subject, to, content)

sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
response = sg.client.mail._('send').post(request_body: mail.to_json)

However, I'd like to replace the content with my old Mailer Templates I used in Rails. Is this possible?

1
How can you use a Mailer Template with sg.client.mail._('send').post(request_body: mail.to_json)? - slindsey3000
@slindsey3000 that is what I was trying to figure out if it was possible. I ended up using SMTP as discussed below - R. Byer

1 Answers

1
votes

You can use their SMTP API which allows you to define or use your email templates in your rails app.

example send guild ruby