Ruby on Rails, Sending Email with sendmail on Ubuntu VPS

04.05.2015

config/environments/production.rb

config.action_mailer.delivery_method = :sendmail
config.action_mailer.default_url_options = { host: "yourdomain.com", port: 25}

Install sendmail

$ sudo apt-get install sendmail

Configure hosts file correctly:

$ nano /etc/hosts

And make sure the line looks like this:

127.0.0.1 localhost localhost.localdomain yourhostnamehere

Run hostname if you don’t know your hostname.

Reload /etc/hosts, so that the previous changes take effect

sudo /etc/init.d/networking restart that works but seems to be deprecated, better use:

$ /etc/init.d/networking stop
$ /etc/init.d/networking start

Run the sendmail config and answer ‘Y’ to everything:

$ sendmailconfig

Sources
https://holarails.wordpress.com/2013/11/17/configure-sendmail-in-ubuntu-12-04-and-make-it-fast/

http://collinhenderson.com/post/48046976172/a-fix-for-slow-sendmail-on-ubuntu