OpenRain.com uses Google Apps For Your Domain, and all email flows throw Google’s servers. Unfortunately, Rails 1.2.2 can’t send via smtp.google.com out of the box. As originally pointed out by Anatol Pomozov there is a solution. Here’s the simple version tested with Rails 1.2.2.
- Save this code as lib/smtp_tls.rb within your rails app.
- Add this code to config/environment.rb.
- Use ActionMailer as normal.
Updated 2008.01.04: The original link was b0rken, so I pastied the code instead.
23 replies on “Configuring Rails To Use Gmail's SMTP Server”
Just a note: if you’re copying and pasting the code from this page, know that the single- and double-quotes are being pasted as non-parsable versions. You’ll need to re-type those quotes to avoid read errors.
[…] PrestonLee.com » Configuring Rails To Use Gmail’s SMTP Server […]
action_mailer_tls seems to work with the same config I used with Rails 1.1.6
The links to the code seem to be broken. Is the code available anywhere else?
Thanks
The links seem to be working fine this morning. Maybe he just had some downtime yesterday.
[…] ที่มา: PrestonLee.com […]
The website was down for me too.
I searched google for the link:
http://blog.pomozov.info/posts/how-to-send-actionmailer-mails-to-gmailcom.html
and was able to get the code via the google cache.
[…] Enjoy! Thanks to Preston Lee for pointing this out. And, of course, Anatol’s smtp_tls library can also be used directly from any other Ruby application if you like! […]
I have copied-pasted the code from google cache to http://21croissants.blogspot.com/2007/08/configuring-rails-to-use-gmails-smtp.html
[…] http://www.prestonlee.com/archives/63 http://21croissants.blogspot.com/2007/08/configuring-rails-to-use-gmails-smtp.html […]
Guyz, I am trying to send multiple mails so i have to authenticate multiple times which consumes a hell lotta time, can anyone suggest a way.
@SandyTheFire
I’m not sure how to best deal with that within Rails, but you could use your own SMTP server instead. If your sending a ton of emails you may need to do that anyway to avoid getting slapped by Google.
It’s also available from our SVN repo
https://openrain.com/opensource/public/rails/plugins/action_mailer_tls/
-M
[…] Note: I previously wrote about how to do this for Rails 1.2.x here. […]
Gmail will limit you to send 500 emails per day.
You won’t be able to change the “from” parameter.
Perfect for personal use.
/Users/prat/lib/rubygems/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:266:in `load_missing_constant’: uninitialized constant ActionMailer (NameError)
Got this Error when starting mongrel.
[…] ä¸è¿‡åŽæ¥åœ¨ä¸€ç¯‡ Blog 的评论ä¸çœ‹åˆ°è¯´ Gmail é™åˆ¶ä¸€å¤©åªèƒ½å‘ 500 å°é‚®ä»¶ï¼ŒGoogle 了一下貌似确有æ¤äº‹ï¼Œè¿˜æ²¡æœ‰äº²è‡ªè¯å®žã€‚ […]
gracias por tu instructivo, por el cual logre lo que necesitaba.
saludos desde colombia
[…] five […]
For the ‘load_missing_constant’ error, here is the fix…
Put
require ‘smtp_tls’
require ‘action_mailer’
into environment.rb.
Alright folks,
great tutorial – it came in very handy today.
I would just like to add, for anyone who cares, that the code you need to insert into environment.rb, needs to go AFTER everything else in the file. i.e. after the ‘end’ statement.
anyway, thanks a lot for this, I really needed it.
Cheers
[…] account you need to do something special in your rails app. I highly recommend you have a look at Preston Lee’s blog post for […]
Thank you!!!!!