Sachin R
Sachin R

Reputation: 11876

Rails 3 - Production environment - smtp email issue

I am using smtp settings for sending mails in rails 3. It works fine when sendmail and postfix services are running. But when I stopped those two services then mails stop sending and giving me connection error.

Error log -

ERROR -- : (Errno::ECONNREFUSED): Connection refused - Connection refused
org/jruby/ext/socket/RubyTCPSocket.java:126:in `initialize'
org/jruby/RubyIO.java:1178:in `open'

Upvotes: 3

Views: 220

Answers (1)

jayesh
jayesh

Reputation: 2492

If you do not pass any config in your application then it will try to connect localhost on port 25. In your case, this has stopped your SMTP services, that's why you are getting an error.

So, please add these details below in your config .. in application.rb or depending on your need you can put on development.rb or production.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    :address        =>  smtp.mailgun.org, # smtp service provider name
    :port           => 587, # port number of smtp server 
    :authentication => 'plain', #plain ////
    :user_name      => '', #user name
    :password       =>'', #password
    :domain         =>  '',#domain name 
    :enable_starttls_auto => true
}

Upvotes: 5

Related Questions