Has anyone gotten an html email to work at gmail.com? I have probably
tried every combination under the sun.
Can anyone who has gotten emails to correctly render in GMail post their
actionmailer method call that sets the multipart content.
I have seen many html formatted emails work in GMail so I know this can
be done.
-Aryk
On Dec 19, 2006, at 10:09 PM, Aryk G. wrote:
-Aryk
If you happen to be following the Rails Recipes for this, I ran into
trouble until changing the name of the file from
“multipart_alternative.rhtml” to “multipart_alternative_html.rhtml”.
There seemed to be a conflict between the content_type “multipart/
alternative” and the file-name-based magic of setting the content type.
I think you can change the name to anything other than
“multipart_alternative.rhtml” and get the same results.
Look at the generated email and see if the HTML part is given a MIME
type of “text/html” or “multipart/alternative”. (I dealt with this
months ago and don’t recall any more specifics.)
-Rob
Recipe 67:
GracefullyDegradingRichTextEmails/app/models/notifier.rb
#—
Excerpted from “Rails Recipes”
We make no guarantees that this code is fit for any purpose.
information.
#—
class Notifier < ActionMailer::Base
def multipart_alternative(recipient, name, sent_at = Time.now)
subject “Something for everyone.”
recipients recipient
from ‘[email protected]’
sent_on sent_at
content_type “multipart/alternative”
part :content_type => "text/plain",
:body => render_message("multipart_alternative_plain", :name
=> name)
part :content_type => "text/html",
:body => render_message("multipart_alternative_html", :name =>
name)
#…^^^^^
end
def implicit_multipart(recipient, name, sent_at = Time.now)
subject “Something for everyone.”
recipients recipient
from ‘[email protected]’
sent_on sent_at
body(:name => name)
end
end
END
Rob B. http://agileconsultingllc.com
[email protected]
Rob,
Thanks for the post. Unfortunately, I tried the code from the recipes
book and it does work. This is what I currently have:
def invite(email, sender)
subject sender.full_name + ’ has invited you to Mixbook.com’
recipients email
from ‘[email protected]’
sent_on Time.now
content_type “multipart/alternative”
# headers = {“MIME-Version”=>1.0}
# body ‘sender’ => sender
part :content_type=> "text/plain",
:body => render_message("invite_plain",:sender=>sender)
part :content_type=> "text/html",
:body => render_message("invite_html", :sender=>sender)
end
Bear in mind, that this works in outlook express, just not on GMail’s
website. Am I somehow coding the email incorrectly. I include style
information in the actual email because I don’t know where else to put
it. I doubt that’s the problem though.
AYYYYY…
I figured out what I was doing wrong.
Gmail strips your html code of all id and class tags along with
stylesheets if you those.
You also cant float divs. You need to use archaic tables when dealing
with gmail and most other clients.