Here is how you can use gmail as free SMTP server so that you can use it to send emails in rails application for free.
1. You have to install the actionmailer-tls plugin into your rails project
Gmail only support SSL SMTP mailing service. So if you can’t create a SSL connection to its SMTP server, you can’t send emails through them. This plugin is created to solve this problem.
2. Change your environment.rb
First you have to make sure the plugin is loaded. At the end of the environment.rb, put the following:
require 'smtp_tls'
3. Add mailer configuration
You can put this in environment.rb or environments/development.rb or environments/production.rb depends on which environment you want to use this mailing function.
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:domain => INSERT_MAIL_DOMAIN,
:user_name => INSERT_MAIL_ADDRESS,
:password => INSRT_MAIL_PASSWORD
}
Now trying sending emails with your rails application. Now depends on your ruby version, you may see the following errors:
ERROR ArgumentError: wrong number of arguments (3 for 2)
FILE config/initializers/smtp_tls.rb, line 8
This is obvious that the function check_auth_args is expecting 2 argument, while 3 is given. So let’s fix it:
#check_auth_args user, secret, authtype if user or secret if RUBY_VERSION > "1.8.6" check_auth_args user, secret # for rails 1.8.7 else check_auth_args user, secret, authtype if user or secret # for rails 1.8.6 end
Now you should be able to send emails, however, gmail has a 500 mails/day limit. In this case, you may set up multiple accounts, and rotate the settings when sending email error is caught.





Shanison,
A big thank you for documenting that. I could not believe that this is happening as of today.
http://kedarm.posterous.com/rails-30-actionmailer-difficulties-in-sending
Regards,
Kedar
Kedar,
Thanks for referring my post in your website. Glad that it helps.
Shanison