Tuesday, September 7, 2010

Sending HTML mail in rails

Hi pals,

If all the mails that you send are in HTML format. its simple. Specify this line in environment.rb

ActionMailer::Base.default_content_type = "text/html"


If only one action has to be in HTML mail, specify 'content_type' in that action.

content_type "text/html"

example,

def signup_notification(recipient)
recipients recipient.email_address_with_name
subject "New account information"
from "system@example.com"
content_type "text/html"
end

cheers,
Sri

No comments: