fast-mailer 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +20 -6
- data/VERSION +1 -1
- data/lib/fast-mailer.rb +2 -0
- data/lib/fast-mailer/exceptions.rb +8 -0
- data/lib/fast-mailer/file_blacklist.rb +24 -0
- data/lib/fast-mailer/smtp.rb +9 -0
- metadata +5 -3
data/README.md
CHANGED
@@ -66,16 +66,30 @@ This will cause FastMailer::SMTP to use FastMailer::MockSMTP rather than Net::SM
|
|
66
66
|
You can then find your sent emails in FastMailer::MockSMTP.deliveries.
|
67
67
|
|
68
68
|
|
69
|
-
|
69
|
+
Parallelisation
|
70
70
|
---------------
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
To send a large number of emails, you can use the FastMailer::Mailer class. Create
|
73
|
+
it as an SMTP instance, but include an additional option :max_connections. When
|
74
|
+
calling send_all with a mail iterator (any object yielding Mail instances on :next),
|
75
|
+
:max_connections threads will be spawned, sending mail from the generator in parallel.
|
76
|
+
|
77
|
+
emails = [mail_1, mail_2, ..., mail_n]
|
78
|
+
mailer = FastMailer::Mailer.new
|
79
|
+
mailer.send_all emails.to_enum
|
80
|
+
|
81
|
+
Note that the generator must not return modified instances of the same object
|
82
|
+
multiple times, since up to :max_connections mails will be processed at the same
|
83
|
+
time.
|
84
|
+
|
85
|
+
The :send_all call will not return until all mails have been sent. At this point, all
|
86
|
+
spawned threads will have stopped.
|
87
|
+
|
88
|
+
|
89
|
+
Coming features
|
90
|
+
---------------
|
75
91
|
|
76
92
|
* Logging: When sending large batches, sometimes things go wrong. If we keep track
|
77
93
|
of which mails have been sent and which have failed, we reduce the risk of finding
|
78
94
|
ourselves wondering which of our users have received the message and which we need
|
79
95
|
to send to.
|
80
|
-
|
81
|
-
* Blacklisting: block addresses so they cannot be sent to.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/fast-mailer.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
module FastMailer
|
3
|
+
|
4
|
+
# Simplistic blacklist implementation. Reads a text file with a single
|
5
|
+
# email address per line into memory. Addresses found are considered
|
6
|
+
# blacklisted.
|
7
|
+
class FileBlacklist
|
8
|
+
|
9
|
+
def initialize(filename)
|
10
|
+
@blacklist = []
|
11
|
+
|
12
|
+
File.open(filename, 'r:utf-8') do |file|
|
13
|
+
while line = file.gets
|
14
|
+
@blacklist << line.strip
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def blacklisted?(email)
|
20
|
+
@blacklist.include?(email)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/fast-mailer/smtp.rb
CHANGED
@@ -81,6 +81,15 @@ module FastMailer
|
|
81
81
|
if message.blank?
|
82
82
|
raise ArgumentError.new('A encoded content is required to send a message')
|
83
83
|
end
|
84
|
+
|
85
|
+
if @configuration[:blacklist]
|
86
|
+
destinations.each do |email|
|
87
|
+
if @configuration[:blacklist].blacklisted?(email)
|
88
|
+
raise FastMailer::BlacklistError.new(email)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
84
93
|
|
85
94
|
begin
|
86
95
|
@smtp.sendmail(message, envelope_from, destinations)
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Erik Hansson
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-04 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -137,6 +137,8 @@ files:
|
|
137
137
|
- bin/tt
|
138
138
|
- bin/unit_diff
|
139
139
|
- lib/fast-mailer/configuration.rb
|
140
|
+
- lib/fast-mailer/exceptions.rb
|
141
|
+
- lib/fast-mailer/file_blacklist.rb
|
140
142
|
- lib/fast-mailer/mailer.rb
|
141
143
|
- lib/fast-mailer/mock_smtp.rb
|
142
144
|
- lib/fast-mailer/smtp.rb
|