Skip to content
This repository was archived by the owner on May 5, 2020. It is now read-only.

Add support for SMTP directly over SSL #59

Open
wants to merge 1 commit into
base: 2-3-github
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions actionmailer/lib/action_mailer/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ module ActionMailer #:nodoc:
# This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.
# * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server and starts to use it.
# It works only on Ruby >= 1.8.7 and Ruby >= 1.9. Default is true.
# * <tt>:enable_tls</tt> - When set to true, enables SMTP directly over SSL/TLS. Default is false.
#
# * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
# * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
Expand Down Expand Up @@ -299,6 +300,7 @@ class Base
:password => nil,
:authentication => nil,
:enable_starttls_auto => true,
:enable_tls => false,
}
cattr_accessor :smtp_settings

Expand Down Expand Up @@ -712,6 +714,7 @@ def perform_delivery_smtp(mail)

smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
smtp.enable_starttls_auto if smtp_settings[:enable_starttls_auto] && smtp.respond_to?(:enable_starttls_auto)
smtp.enable_tls if smtp_settings[:enable_tls] && smtp.respond_to?(:enable_tls)
smtp.start(smtp_settings[:domain], smtp_settings[:user_name], smtp_settings[:password],
smtp_settings[:authentication]) do |smtp|
smtp.sendmail(mail.encoded, sender, destinations)
Expand Down