Complete sample for ActionMailer to send emails with GMAIL

I would like to test my ActionMailer class, but I don't have smtp server. I would like to use gmail to send such emails. Can someone provide a sample with all the necessary configurations both in google and in any configuration files in the application?

+3
source share
2 answers

GMail has only SSL SMTP, so you must create an SSL-SMTP connection through Net :: SMTP.

Check out this article:

+5
source

SSMTP. SMTP- SMTP-. Unix (Ubuntu hardy ) sendmail.

Ubuntu, apt-get install ssmtp, .

.

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=aspmx.l.google.com
mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
rewriteDomain=example.com

# The full hostname
hostname=yourhostname.example.com

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

# should turn on SSL & auth to google SMTP server
# TODO change this user
UseTLS=YES
UseSTARTTLS=YES
AuthUser=yourgoogleuser@example.com.com
AuthPass=yourgooglepassword

environment.rb production/environment.rb:

ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.raise_delivery_errors = true
+4

All Articles