Hedge
Hedge

Reputation: 16748

Rails Action Mailer doesn't send mails

I'm trying to send mails through rails using Action Mailer and the Googlemail-SMTP-server, but it doesn't work. What am I doing wrong?

Here's the config I use (I also tried a local Relay-Server without authentification which also didn't work):

# Action Mailer config
config.action_mailer.smtp_settings = {
# Gmail Account
:tls => true,
:address => "smtp.googlemail.com",
:port => "587",
:domain => "localhost",
:authentication => :plain,
:user_name => "[email protected]",
:password => "dsgdes" 

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = { :host => "localhost:80" }
config.action_mailer.default_charset = "utf-8"

Upvotes: 5

Views: 6750

Answers (4)

Krishna Singh Shahi
Krishna Singh Shahi

Reputation: 11

In my project I use these lines and got success to run mycode:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = smtp
config.action_mailer.smtp_settings = {
address: 'smtp.sendgrid.net',
port: 587, domain: '3SClub.com',
user_name: ENV['SENDGRID_USERNAME'],
password: ENV['SENDGRID_PASSWORD'],
authentication: :plain,
enable_starttls_auto: true
}
config.action_mailer.default_url_options = {:host =>    "localhost:3000"}

NOTE:

  1. check your domain name.

  2. change your authentication into :login

Upvotes: 0

d sharpe
d sharpe

Reputation: 189

This is what I use succesfully

config.action_mailer.smtp_settings = {
  :tls => true ,
  :enable_starttls_auto => true ,
  :authentication => :login ,
  :address => "smtp.gmail.com" ,
  :port => 587 ,
  :domain => "smtp.gmail.com" ,
  :user_name => "[email protected]" ,
  :password => "yourpassword"

Upvotes: 0

Fusco
Fusco

Reputation: 64

:domain => 'your_domain'

example http://asciicasts.com/episodes/206-action-mailer-in-rails-3

Upvotes: 0

apneadiving
apneadiving

Reputation: 115511

I guess, your domain parameter is wrong. I wrote an initializer in my config/initializers directory, it looks like this:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => "587",
  :domain               => 'gmail.com',
  :user_name            => '[email protected]',
  :password             => 'dsgdes',
  :authentication       => 'plain',
  :enable_starttls_auto => true  }

Upvotes: 3

Related Questions