0

I'm using the SendGrid API and I am trying to find a cleaner way to generate HTML content to send as an email.

I would like to try and use some of my current mailer html template files and pass a database object to them to receive the response, but I am not sure how that is done or if it can be. Here is essentially what I am wanting to do.

@user = User.find(1)
html_content = render "mailers/my_mailer", user: @user
@user.send_html_content(html_content)

Maybe there is a better way of doing this but I'm not sure. Any tips would be appreciated!

Thanks in advance.

1
  • 1
    There's a gem for SendGrid which will integrate with ActionMailer. Then you can send mail as normal. Is there a reason you can't use that? Commented Jan 16, 2018 at 22:20

1 Answer 1

1

Look up render_to_string.

It renders and returns a string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.