I'm a Rails newbie using version 3.1.4 for my Heroku (Cedar stack) app. I'm trying to figure out why my app is sending blank emails using Sendgrid, and I haven't had much success with their support after raising a ticket three business days ago, so I'm hoping someone here might be able to help (tried searching the net and this group for blank emails, as well as posting on Stackoverflow, too). I'm connecting to Sendgrid OK because the emails are sending...they're just blank (actually in hotmail the body says "This is a multi-part message in MIME format... ----." and there's a small attachment in gmail that has that same text - in Yahoo mail it's blank though). I followed these directions (https://devcenter.heroku.com/articles/sendgrid), so I have: my initializer/mail.rb ActionMailer::Base.smtp_settings = { :address => 'smtp.sendgrid.net', :port => '587', :authentication => :plain, :user_name => ENV['SENDGRID_USERNAME'], :password => ENV['SENDGRID_PASSWORD'], :domain => 'heroku.com'}ActionMailer::Base.delivery_method = :smtp My mailer (notifier.rb), like this: class Notifier < ActionMailer::Base helper :application default_url_options[:host] = "foo.com" def registration_confirmation(user) from 'Foo <info@foo.com>' @user = user subject "Welcome to Foo, #{@user.first_name}!" recipients "#{@user.first_name} <#{@user.email}>" sent_on Time.now end a text version (registration_confirmation.text.erb and an html version registration_confirmation.html.erb). when I check the Heroku logs, it doesn't report any errors and it indicates both views rendered successfully. I have put the who output from the logs in this gist: https://gist.github.com/2765790 If someone could please help this newbie learn what he's doing wrong, that would be hugely appreciated. Thank you!
on 2012-05-23 03:13
on 2012-05-24 17:35
Hey,
I'm Swift, one of the developer evangelists over at SendGrid. Sorry
that we didn't get back to you on our support channel - we get a high
volume of requests and sometimes things slip through the cracks.
Your problem is that you're using a deprecated syntax for composing
the email. The preferred method is to use the mail function:
def
registration_confirmation(user)
mail(:from => 'Foo
<info@foo.com>',
:subject => "Welcome to Foo,
#{user.first_name}!",
:to => "#{user.first_name} <#{user.email}
>")
end
You can find the docs for ActionMailer here:
http://guides.rubyonrails.org/action_mailer_basics.html
They're pretty extensive and definitely worth the read.
Let me know if you have any more issues!
- Swift
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.