Ask A Question

Notifications

You’re not receiving notifications from this thread.

Upload image and send email without saving to the database

Lee Terng Gio asked in Rails

I recently tried to implement summernote to my rails app. I can send email and everything works fine. But I want to upload image and send the email, but the email received shows that the image was broken. How do I fix it?

The email that attached with uploaded image doesn't need to be saved into database. I just want to send the email.

My mailer.rb
def message_send(candidate_mail)
@candidate_mail = candidate_mail
mail(
to: "#{@candidate_mail.to}",
from: "#{@candidate_mail.from}",
subject: "#{@candidate_mail.subject}",
body: "#{@candidate_mail.body}",
content_type: "text/html",
important: true,
inline_css: true,

)
end

Reply
I can send the email, the problem is the image is broken in the received email. I have seen documentation of how to add attachments to email, but that's not what I want because those are normally refer to public file or something or they hard code it. I use summernote to save the text and image, and they render properly in view, but the image shows broken when it's being sent out as an email. For your information, the image is encoded in Base 64 when save into database.
Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.