How do I send html emails with ActionMailer?

Send HTML emails with inline images with ActionMailer

  • I have a simple ActionMailer class like this: class MyMailer < ActionMailer::Base def mail(from, to, cc, bcc, subject, message, sent_at = Time.now) @subject = subject @recipients = to @from = from @cc = cc @bcc = bcc @sent_on = sent_at @body["message"] = message @headers = {} end end And I ue it like this from a controller: MyMailer.deliver_mail(mail.from, mail.to, mail.cc, mail.bcc, mail.subject, mail.message) I prefer to keep it simple with no templates or such, and it is a webservice with no views. How do I change it to be able to send HTML mails with embedded images (in img tags i mean)? I need to attach the images woth the correct mime-type and also set the body with the correct mime-type, but how? Thank you

  • Answer:

Neigaard at Stack Overflow Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.