How to include urls when evoking ActionMailer::Base.mail

23 Views Asked by At

I am sending an email with Rails like so:

ActionMailer::Base.mail(
  from: "[email protected]",
  to: "[email protected]",
  subject: "test",
  body: "test"
).deliver

I want the body to include [test](https://ham.com), but this markdown is not parsed, and <a href="https://ham.com">test</a> doesn't work either.

How can I format my url so it gets formatted properly?

1

There are 1 best solutions below

1
smathy On BEST ANSWER

If you want it sent as HTML then you need to provide the Content-Type header (content_type: "text/html"), although it's better to follow the normal approach of a mailer subclass, and using templates.