Darme
Darme

Reputation: 7083

Sending multipart emails with Rails: how to favor the HTML version over the plain text one?

I setup a standard rails mailer with multipart view following the official guide, like this:

mail(to: user.email, subject: "Welcome") do |format|
   format.html { render layout: 'my_layout' }
   format.text
end

With the clear and common intent to give priority to the html version of the message, only to find that, as this article points out, calling format.html before the format.text makes a lot of mail clients to show only the text version of the message. In my case I verified (and struggled with) that with both Gmail and Mozilla Thunderbird.

Is there a reliable solution to give precedence to the html version?

Upvotes: 9

Views: 1477

Answers (1)

Darme
Darme

Reputation: 7083

The only solution I found so far is to switch format.html with format.text so that the text format is called before the html one. Which is exactly the opposite of what one would expect.

Upvotes: 7

Related Questions