0

I am getting the following error while trying to send an email.

 Errno::ECONNREFUSED: Connection refused - connect(2)

Code that sends the email

 Reminder.new_event(event_owner.email).deliver!

My Email settings are

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :address => "smtp.gmail.com",
    :port => 587,
    :domain => "google.com",
    :authentication =>"login",
    :user_name => "email address",
    :password => "password",
    :enable_starttls_auto => true
  }

Could you please help me. Thanks

1
  • Is it working with any other SMTP setting? I mean to another email server? You need to localize if the problem is only connecting to gmail or to all smtp servers. Is this problem intermitten or has it never ever worked. Commented Dec 23, 2010 at 8:54

3 Answers 3

4

Try with

config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "google.com",
:authentication =>"plain",
:user_name => "email address",
:password => "password",
}

Note the:

:authentication =>"plain",

and

:enable_starttls_auto => true

is the default value, no need to specify it.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer. Now I dont see any error in the log but still the mail is not getting delivered. When I tried to execute the method from the rails console, I am getting the same error
1

Try the following in your config/application.rb file :

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address => "smtp.gmail.com",
  :port => 587,
  :domain => "google.com",
  :authentication =>"plain",
  :user_name => "email address",
  :password => "password",
  :enable_starttls_auto => true
}

To send the email, try (note, without ! at the end)

Reminder.new_event(event_owner.email).deliver

And try sending a test email to an email address that is not the same as the sending gmail account (as gmail won't allow that through).

Comments

0

I did only have success when omitting both :port and :domain, but had to set :tls to true.

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = { 
    :tls => true,
    :address => "smtp.gmail.com", 
    :authentication => :plain, 
    :user_name => "full-email-address", 
    :password => "password" 
  } 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.