I have a Ruby on Rails 4.1 application running with nginx + Unicorn. When I try to send email that way:
ActionMailer::Base.smtp_settings = {
:openssl_verify_mode => 'none'
}
ActionMailer::Base.mail(:from => "info@my_ip", #I don't have a domain name.
:to => "my_email",
:subject => subject, :body => body).deliver
This produce the error:
Connection refused - connect(2) for "localhost" port 25
My nginx configuration:
worker_processes 1;
user michael michael;
pid /tmp/nginx.pid;
events {
worker_connections 128;
accept_mutex off;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
gzip on;
upstream msystem_server {
server unix:/srv/msystem/shared/.unicorn.sock fail_timeout=0;
}
server {
listen 80 default deferred;
client_max_body_size 10M;
server_name my_ip;
keepalive_timeout 5;
root /srv/msystem/current/public;
try_files $uri/index.html $uri.html $uri @msystem;
location @msystem {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://msystem_server;
}
}
}
Sorry for my English. I don't know, what else to say. But stackoverflow says, that I should.
It seems like you don't have any mailer service running on the port 25
.
From the documentation:
:port - On the off chance that your mail server doesn't run on port 25, you can change it.
Reading documentation further:
delivery_method - Defines a delivery method. Possible values are :smtp (default), :sendmail, :test, and :file.
So if you have it set to :smtp
you may want to change the port to 587
, which is now almost default for the main external services. If you set :sendmail
however, you should set the corresponding port for your local service.