Upload image and send email without saving to the database
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
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
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.