Having Typo sending emails using Gmail (or any other TLS enabled SMTP)

By default, neither Typo nor Ruby On Rails can send emails using a TLS enabled server. To have Typo sending you new posts and comments notification, or even your admin password, you’ll have to tweak it a little bit. Here’s a step by step tutorial.

First, you’ll have to install the ActionMail Optional TLS plugin. From your Typo directory, just run:

./script/plugin install http://github.com/collectiveidea/action_mailer_optional_tls

Easy as pie isn’t it?

Then, in your config/environment.rb, replace the following lines:

begin
  mail_settings = YAML.load(File.read("#{RAILS_ROOT}/config/mail.yml"))

  ActionMailer::Base.delivery_method = mail_settings['method']
  ActionMailer::Base.server_settings = mail_settings['settings']
rescue
  # Fall back to using sendmail by default
  ActionMailer::Base.delivery_method = :sendmail
end

With:

ActionMailer::Base.smtp_settings = {
   :tls => true,
   :address => "smtp.gmail.com",
   :port => "587",
   :domain => "YOURDOMAIN",
   :authentication => :plain,
   :user_name => "GOOGLEUSERNAME",
   :password => "GOOGLEPASSWORD"
 }

Restart your application. Enjoy having Typo sending you emails from Gmail.

Fri, 16 Apr 2010 19:07 Posted in

  1. Avatar

    By Silvio Relli about 1 month later:


    If you are on ruby 1.8.7 and you are getting the error “Net::SMTPAuthenticationError: 530 5.7.0 Must issue a STARTTLS command first.” try using :enable_starttls_auto => true, instead of :tls => true, That worked for me! Instead if you are in ruby 1.8.6 you’ll have to install this plugin: http://github.com/openrain/action_mailer_tls Finally that’s a good tutorial on the matter: http://www.justinball.com/2009/06/25/sending-email-with-ruby-on-rails-2-3-2-and-gmail/

Comment Having Typo sending emails using Gmail (or any other TLS enabled SMTP)


RSS