maedana-ar_mailer 2.1.5 → 2.1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/action_mailer/ar_mailer.rb +29 -1
- metadata +1 -1
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'smtp_tls' unless Net::SMTP.instance_methods.include?("enable_starttls_auto")
|
2
|
+
|
1
3
|
##
|
2
4
|
# Adds sending email through an ActiveRecord table as a delivery method for
|
3
5
|
# ActionMailer.
|
@@ -28,11 +30,37 @@ class ActionMailer::Base
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
33
|
+
def perform_delivery_smtp(mail)
|
34
|
+
destinations = mail.destinations
|
35
|
+
mail.ready_to_send
|
36
|
+
sender = (mail['return-path'] && mail['return-path'].spec) || mail['from']
|
37
|
+
|
38
|
+
settings = [
|
39
|
+
smtp_settings[:domain],
|
40
|
+
(smtp_settings[:user] || smtp_settings[:user_name]),
|
41
|
+
smtp_settings[:password],
|
42
|
+
smtp_settings[:authentication]
|
43
|
+
]
|
44
|
+
|
45
|
+
smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
|
46
|
+
if smtp.respond_to?(:enable_starttls_auto)
|
47
|
+
smtp.enable_starttls_auto unless smtp_settings[:tls] == false
|
48
|
+
else
|
49
|
+
settings << smtp_settings[:tls]
|
50
|
+
end
|
51
|
+
|
52
|
+
smtp.start(*settings) do |smtp|
|
53
|
+
smtp.sendmail(mail.encoded, sender, destinations)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
31
57
|
def perform_delivery_smtp_failover_activerecord(mail)
|
32
58
|
perform_delivery_smtp mail
|
33
59
|
rescue Exception => e
|
34
60
|
perform_delivery_activerecord mail
|
35
|
-
|
61
|
+
logger.error e
|
62
|
+
e.backtrace.each { |line| logger.error line}
|
63
|
+
after_failed_delivery_smtp_mail(e) if defined? self.after_failed_delivery_smtp_mail
|
36
64
|
end
|
37
65
|
|
38
66
|
end
|