Last week I run into some problems while configuring the ActionMailler with Gmail. I have already some applications in production using this method. However this one, using ruby 1.8.7 and rails 2.3.3 gave me extra trouble.

Gmail requires TLS, older versions of ruby and rails do not support that, the work around was a pluging to enhance it (ActionMailerTLS). But if you are using Ruby 1.8.7 with Rails 2.2.1, or later versions, you don’t need plugins anymore, you only need to follow this simple instructions.

Add the following lines in your config/enviroments/production.rb

```
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = YAML.load File.open("#{RAILS_ROOT}/config/mailer.yml")
```

And then create the yaml file config/mailer.yml :

```
---
:enable_starttls_auto: true # This is how you tell ActionMailler to use tls
:address: smtp.gmail.com
:port: 587
:domain: gmail.com
:user_name: my_username #You should type your username, you should not include the "@gmail.com".
:password: my_password #You should type your password
:authentication: :plain
```

That’s it!

Now take a look in this notifier class example:

```
class Notifier < ActionMailer::Base
def activation_instructions(user)
@recipients = "#{user.email}"
#@from = "Miguel <my_username@gmail.com>" # Doesn't work anymore
@from = "my_username@gmail.com"
@subject = "[Card-Sorting] "
@sent_on = Time.now
@subject += "Important"
@body[:user] = user
end
end
```

There is a lack of backward compatible. Due to some changes in the latest versions you cannot use that syntax anymore, if you are upgrading from old versions be careful, you should only simply specify your email to get it correctly parsed.