mailer_ext.rb

the patch supplied by https://rails.lighthouseapp.com/projects/8994/tickets/1731-make-enable_starttls_auto-opt-in-in-actionmailer#ticket-1731-18 - hongbo yang, 2014-06-20 10:14

Download (646 Bytes)

 
1
class ActionMailer::Base
2

    
3
  def perform_delivery_smtp(mail)
4
    destinations = mail.destinations
5
    mail.ready_to_send
6
    sender = mail['return-path'] || mail.from
7

    
8
    smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
9
    if smtp_settings[:ssl]
10
      smtp.enable_tls()
11
    else
12
      smtp.enable_starttls_auto if smtp_settings[:enable_starttls_auto] && smtp.respond_to?(:enable_starttls_auto)
13
    end
14
    smtp.start(smtp_settings[:domain], smtp_settings[:user_name], smtp_settings[:password],
15
               smtp_settings[:authentication]) do |smtp|
16
      smtp.sendmail(mail.encoded, sender, destinations)
17
    end
18
  end
19

    
20
end