Send HTML markup email with attachment

So in my app a user can create the body of an email they send to “contacts” they have in the app.

The app uses a CKEditor textbox for the user to enter the body of the email. They can also attach a file to the email.

Using this code the email gets sent the file is attached properly but all of the HTML tags are visible in the body of the email.


@file = EmailFile.create! file: params[:attachment]
@attachment_path = @file.file.url
@file_name = @file.
email_params = {

If you do this it uses this body option instead of your template. It looks like when you use this form of mail, it will always set the content type of the entire message to text/html, which isn’t what you want: you want the overall message to be a multipart one, and the part derived from the body option to be text/html

I would suggest not setting body here at all (or content type). and letting it render your template (which I think is what you probably thought it was doing at all). You’ll need to set @body, as you would with a controller and its view