Sending e-mails with :sendmail in Rails 3

Standard

If you have a Linux Server and you want to send emails in your Rails Application using your own email server please check this. We are using ssmtp.

Put this in your environment.rb:

ActionMailer::Base.delivery_method = :sendmail
        ActionMailer::Base.sendmail_settings = {
          :location => "ssmtp",
          :arguments => "-i"
        }

Common Mistakes

Errno::EPIPE: Broken pipe

Maybe cause you are using the argument “-t” rather than “-i”.

SSMTP is a simple and powerful way to send e-mails, mainly now in your rails application. = )

Sending Emails from a Ubuntu Server – GMail

Standard

1)Instal SSMTP:

sudo apt-get install ssmtp

2)Edit /etc/ssmtp/ssmtp.conf

mailhub=smtp.gmail.com:587
hostname=USER@MYDOMAIN.com
root=USER@MYDOMAIN.com
AuthUser=USER@MYDOMAIN.com
AuthPass=PASSWORD
UseSTARTTLS=yes
UseTLS=yes
FromLineOverride=yes

3)Edit /etc/ssmtp/revaliases

This step is important!

root:USER@MYDOMAIN.com:smtp.gmail.com:587
matt:USER@MYDOMAIN.com:smtp.gmail.com:587

4)Send a Test E-mail

ssmtp test@test.com
To: Test Guy <test@test.com>
From: Me <USER@MYDOMAIN.com>
Subject: Hello World

Hello world!