action_mailer-logged_smtp_delivery 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d781ad070664a975fffad82071e7aeedf7ed601
4
- data.tar.gz: 761658d0f91601a056abe97f9a3abdddfb51e4b4
3
+ metadata.gz: 7651e5af7c2a110d7f7fc8994118df3a1216d7e4
4
+ data.tar.gz: e81810d05d35b5b9ab7f0db2ef7ce22b0ea770ad
5
5
  SHA512:
6
- metadata.gz: ff13c8e7ee92190f904e893d3a10cca6605a6b9cecff368d71a016289990619b76fa5ddffa18f0909e366a710811e44ed05ff2034f5656d170870b0f82b8ba4b
7
- data.tar.gz: 1c9f076ced8d21c1b81183feb3821748acedc71722f8f063631c1eab5ce0cdd13320b294357000c3c849dead56add05484d426f654e535c2f5285e11bff3bd0f
6
+ metadata.gz: 425765706313e3931e1c6ef65cc8865e3dec2a9fee4d08f7c8b75fd0add33052834ba1a43cbf82c3ac21a0d5f7cdd415db35ed4bb9b4b377c4e3fa0dbd7cf9b2
7
+ data.tar.gz: 8599fbf140a19b58decf53aaa357022fabbed53d9c6571a6d9231f958c8cc55dff59e6a7ddb0d4f31eed56791f8f99f17d7d48e761b313a1f545088c9d444bb7
data/README.md CHANGED
@@ -5,7 +5,7 @@ require 'action_mailer/logged_smtp_delivery'
5
5
  config.action_mailer.logged_smtp_settings = {
6
6
  ... normal smtp settings ...,
7
7
  logger: Logger.new, # progress info
8
- mail_file_logger: Logger.new # log full encoded mails for storage
8
+ mail_file_logger: FileLogger.new # write encoded mails for storage, must return path they were stored in
9
9
  }
10
10
 
11
11
 
@@ -1,86 +1,54 @@
1
1
  require 'action_mailer'
2
- require 'net/smtp'
3
-
4
- module ActionMailer::LoggedSMTPDelivery
5
- class Mailer
6
- def initialize(settings)
7
- @settings = settings
8
- end
9
-
10
- def deliver!(mail)
11
- delivery = SMTPDelivery.new(mail, @settings, @settings.fetch(:logger))
2
+ require 'mail/network/delivery_methods/smtp'
3
+
4
+ class ActionMailer::LoggedSMTPDelivery < Mail::SMTP
5
+ def initialize(settings)
6
+ super
7
+ self.settings[:tls] = (settings[:tls] != false)
8
+ self.settings[:return_response] = true
9
+ self.logger = settings[:logger]
10
+ end
12
11
 
13
- if logger = @settings[:mail_file_logger]
12
+ def deliver!(mail)
13
+ without_bcc(mail) do |mail|
14
+ if logger = settings[:mail_file_logger]
14
15
  path = logger.log(mail.encoded)
15
- delivery.log "stored at #{path}"
16
+ log mail, "stored at #{path}"
16
17
  end
17
18
 
18
- delivery.perform
19
- end
20
- end
21
-
22
- class SMTPDelivery
23
- attr_reader :mail, :settings, :logger
19
+ log_headers(mail)
20
+ log mail, "sender: #{mail.sender}"
21
+ log mail, "destinations: #{mail.destinations.inspect}"
24
22
 
25
- def initialize(mail, settings, logger)
26
- @mail = mail
27
- @settings = settings
28
- @logger = logger
29
- end
30
-
31
- def perform
32
- log_headers
33
- log "sender: #{sender}"
34
- log "destinations: #{destinations.inspect}"
35
-
36
- smtp.start(*settings.values_at(:domain, :user_name, :password, :authentication)) do |session|
37
- response = session.send_message(message, sender, destinations)
38
- log "done #{response.inspect}"
39
- end
40
- end
41
-
42
- def destinations
43
- mail.destinations
44
- end
23
+ response = super
45
24
 
46
- def message
47
- original_bcc = mail.bcc
48
- mail.bcc = nil
49
- mail.encoded
50
- ensure
51
- mail.bcc = original_bcc
25
+ log mail, "done #{response.inspect}"
52
26
  end
27
+ end
53
28
 
54
- def sender
55
- mail.from.first
56
- end
29
+ private
57
30
 
58
- def log_header
59
- settings[:log_header]
60
- end
31
+ attr_accessor :logger
61
32
 
62
- def smtp
63
- smtp_adaptor.new(settings[:address], settings[:port]).tap do |smtp|
64
- smtp.enable_starttls_auto if enable_tls?
65
- end
66
- end
67
-
68
- def log_headers
69
- log "#{log_header}: [#{mail[log_header]}]" if log_header
70
- end
33
+ def without_bcc(mail)
34
+ original_bcc = mail.bcc
35
+ mail.bcc = nil
36
+ yield mail
37
+ ensure
38
+ mail.bcc = original_bcc
39
+ end
71
40
 
72
- def log(message)
73
- logger.info("#{mail.message_id} #{message}")
74
- end
41
+ def log_headers(mail)
42
+ log mail, "#{log_header}: [#{mail[log_header]}]" if log_header
43
+ end
75
44
 
76
- def enable_tls?
77
- settings[:tls] != false
78
- end
45
+ def log_header
46
+ settings[:log_header]
47
+ end
79
48
 
80
- def smtp_adaptor
81
- settings[:adaptor] || Net::SMTP
82
- end
49
+ def log(mail, message)
50
+ logger.info("#{mail.message_id} #{message}")
83
51
  end
84
52
  end
85
53
 
86
- ActionMailer::Base.add_delivery_method :logged_smtp, ActionMailer::LoggedSMTPDelivery::Mailer
54
+ ActionMailer::Base.add_delivery_method :logged_smtp, ActionMailer::LoggedSMTPDelivery
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_mailer-logged_smtp_delivery
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Chapweske
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-24 00:00:00.000000000 Z
11
+ date: 2014-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.19
20
- type: :development
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 4.2.0
23
+ type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 3.2.19
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 4.2.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: minitest
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: 4.7.5
39
+ version: '0'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - "~>"
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: 4.7.5
46
+ version: '0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: minitest-rg
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +86,48 @@ dependencies:
80
86
  - - ">="
81
87
  - !ruby/object:Gem::Version
82
88
  version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: wwtd
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: mailcrate
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 0.0.2
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 0.0.2
117
+ - !ruby/object:Gem::Dependency
118
+ name: byebug
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
83
131
  description: ActionMailer SMTP delivery strategy with advanced logging and Bcc support
84
132
  email:
85
133
  executables: []
@@ -88,7 +136,7 @@ extra_rdoc_files: []
88
136
  files:
89
137
  - README.md
90
138
  - lib/action_mailer/logged_smtp_delivery.rb
91
- homepage: https://github.com/grosser/action_mailer-logged_smtp_delivery
139
+ homepage: https://github.com/zendesk/action_mailer-logged_smtp_delivery
92
140
  licenses:
93
141
  - Apache V2
94
142
  metadata: {}