Redmine/Rails email through Gmail SMTP
December 4th, 2008Here is a bit of help getting Redmine, or any Rails app, to send email over SMTP through an existing Gmail account. It’s quite easy to set up and you gain the usual perks of having everything centralized in a Gmail account. Note: this works with Google Apps for your domain, too.
First you’ll need to install the smtp_tls plugin into your application’s lib directory so you can correctly authenticate. For posterity, I’ve uploaded a copy smtp_tls.rb along with this post.
www@host:~/redmine$ cd lib www@host:~/redmine/lib$ curl -O http://blog.expandrive.com/wp-content/uploads/2008/12/smtp_tls.rb
Redmine utilizes email.yml to configure ActionMailer. Here’s what ours looks like:
production:
delivery_method: :smtp
smtp_settings:
address: smtp.gmail.com
port: 587
domain: gmail.com
authentication: :login
user_name: info@expandrive.com
password: passwordNext, in production.rb makre sure to
require 'smtp_tls'
That’s it, you’re good to go.
If you want to set up any old Rails app [using Action Mailer] to send mail via Gmail, add this to production.rb
require 'smtp_tls' ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.perform_deliveries = true ActionMailer::Base.raise_delivery_errors = true ActionMailer::Base.default_charset = "utf-8" ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :domain => "gmail.com", :authentication => :login, :user_name => "info@expandrive.com", :password => "password", }



December 24th, 2008 at 8:50 am
Thank you very much. Everything works like it should.
December 27th, 2008 at 8:25 pm
I keep getting ‘X An error occurred while sending mail (wrong number of arguments (7 for 6))’
For the life of me — I cannot figure what it might be….
Outgoing email settings
production: delivery_method: :smtp smtp_settings: address: smtp.gmail.com port: 587 domain: gmail.com authentication: :login user_name: mlwhall password: passwordThis is what I have in the email.yml
and I have the loaded the smtp_tls in lib and added require ‘smtp_ls’ to the config/environment/production.rb
Any thoughts that might help?
December 28th, 2008 at 12:14 am
although I’m not sure it’ll help the wrong number of arguments problem you’re seeing, your username should be fully qualified: mlwhall@gmail.com [or whatever it is]
Do you have any cruft in your YML that would cause it to parse weirdly? It looks like you’re using 4 spaces for indenting at 1 level and 2 at another. I’m not positive about the constraints placed upon YML parsing, but I’d fix that
If that fails, try deleting the content in email.yml and put everything in production.rb like in the second half of the example – it’s the same thing.
January 7th, 2009 at 2:51 pm
I really appreciate your work but I’m having a biggest problem right now.
It’s working but throwing a 404 after every page that sends an email. The log is showing a routing error:http://gist.github.com/44389
I can’t get this plugin to work either:http://github.com/collectiveidea/action_mailer_optional_tls/tree/master
Please help. I’m completely stuck right now.
January 20th, 2009 at 10:09 am
Thanks for this post. It worked perfectly for me with Redmine 0.8.0 running on Dreamhost under Phusion Passenger.
July 2nd, 2009 at 9:56 pm
Perfect thank you. that worked great.
July 29th, 2009 at 6:37 am
This works perfect. Thanks!
August 18th, 2009 at 11:33 pm
Thanks man – that worked spot on – much more simplier than other methods out there for Redmine and Gmail functionality.
Thanks for posting!
August 20th, 2009 at 2:19 pm
I’m getting error like this, An error occurred while sending mail (wrong number of arguments (3 for 2))
September 9th, 2009 at 9:24 pm
An error occurred while sending mail (wrong number of arguments (7 for 6))
September 9th, 2009 at 10:34 pm
Try
revert your redmine SVN follow http://github.com/collectiveidea/action_mailer_optional_tls/tree/master
it works !!
September 28th, 2009 at 2:49 am
Thank you for your post. It’s work for me
October 2nd, 2009 at 2:09 pm
It’s not working for me. Can’t realize why. I’m having this return: “wrong number of arguments (3 for 2)” but can’t understand why and where it’s wrong.
December 6th, 2009 at 8:43 pm
i fight with that configuration for hours after i did all that this guys said, and finally i notice that this two files are not equal, so make sure that this two files are identical:
this fixed my problem. (thanks god..)
koko jumbo.
May 4th, 2010 at 1:52 am
Hi All, can anyone tell me how i can configure redmine 0.9.4 to recieve emils from POP3 or smtp Thanx
August 9th, 2010 at 2:37 pm
Thank you…
After a number of searches for the smtp_tls.rb and everything else in the world… finally your post got me things rolling!!!