body templates

43 views
Skip to first unread message

Jared

unread,
Feb 3, 2012, 8:51:08 PM2/3/12
to Ruby's Mail Discussion Group
I'm sure somebody has answered this question, I just haven't found the
thread...

I want to pass some variables into a template, then send this template
as the email body. Here's what I was thinking if you'd like to set me
straight.....

post '/contact' do

name = params[:name]
surname = params[:surname]
email = params[:email]
company = params[:company]
industry = params[:industry]

mail = Mail.new do
from email
to 'jada...@gmail.com'
subject 'you have a contact from ' + name

html_part do
content_type 'text/html; charset=UTF-8'
body haml :message
end
end

mail.delivery_method :sendgrid

mail.deliver

haml :thanks
end

Everything goes out, but the message body doesn't come through.

Thanks in advance!

Andrew Havens

unread,
May 21, 2012, 3:19:55 PM5/21/12
to mail...@googlegroups.com
mail.delivery_method :sendgrid

Sorry, this isn't an answer to your question, but I noticed you are using a custom :sendgrid delivery method. Would you mind sharing with me what exactly your are doing there? I am also using SendGrid, but I just configured the SMTP settings to point to SendGrid. Is your approach better?

Regarding your question, I'm not exactly sure why your html body doesn't come through. I wonder if it has something to do with how you are calling haml within the block you are passing to html_part. The following worked for me, but requires an extra line:

mail.html_part = Mail::Part.new(:content_type => 'text/html', :body => haml(:message))


Andrew

Reply all
Reply to author
Forward
0 new messages