trikle-mail 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/trikle-mail +13 -4
- data/lib/triklemailer.rb +11 -6
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcae7d44b75688c09359e79a19af8e9103b57d7f26956f342e766ce3e1677fae
|
4
|
+
data.tar.gz: c46a0e13c0e5dfb3630d2718f58280c8cccee86aef0f224b1d697332e55e0f4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a897b41c9de4827986b7aac850e31d24aa2c3da34f69676264f71e03d182da271554bb70ff53c99b8ea3ea7791b408d0d07beb5bb9bf7a26ed419447a464bca0
|
7
|
+
data.tar.gz: 13055a1ef42990d12a0dffeaec428ff9e9edb8540bf5d1edd679acbe54a38422546c7eaef10648f901ee61ac852d0d7462b4e116b4547b76a30663da1495e755
|
data/bin/trikle-mail
CHANGED
@@ -29,16 +29,25 @@ class TrikleMail
|
|
29
29
|
c.option '--minutes INTEGER', Integer, 'The number of minutes over which to send the emails'
|
30
30
|
|
31
31
|
c.action do |args, options|
|
32
|
-
recipients = CSV.new(args[0], headers: true).map(&:to_h)
|
33
|
-
sent_file_name = ['sent', options.template.split('.').first].join('_')
|
34
|
-
sent =
|
32
|
+
recipients = CSV.new(File.new(args[0]), headers: true, header_converters: :symbol).map(&:to_h)
|
33
|
+
sent_file_name = "./#{['sent', options.template.split('.').first].join('_')}.csv"
|
34
|
+
sent =
|
35
|
+
if File.exists?(sent_file_name)
|
36
|
+
CSV.new(File.new(sent_file_name), headers: true, header_converters: :symbol).map { |r| r[:email] }
|
37
|
+
else
|
38
|
+
[]
|
39
|
+
end
|
35
40
|
|
36
41
|
mail_options = Triklemailer::Options.new(
|
37
42
|
template: File.read(options.template),
|
38
43
|
template_name: options.template,
|
39
44
|
is_html: options.template.end_with?('html'),
|
40
45
|
from: options.from,
|
41
|
-
subject: options.subject
|
46
|
+
subject: options.subject,
|
47
|
+
port: options.port,
|
48
|
+
host: options.host,
|
49
|
+
username: options.username,
|
50
|
+
password: options.password
|
42
51
|
)
|
43
52
|
|
44
53
|
Triklemailer.send_mail(mail_options, recipients, sent)
|
data/lib/triklemailer.rb
CHANGED
@@ -2,8 +2,12 @@ require 'mail'
|
|
2
2
|
require 'csv'
|
3
3
|
|
4
4
|
module Triklemailer
|
5
|
-
VERSION = '0.0.
|
6
|
-
Options = Struct.new(
|
5
|
+
VERSION = '0.0.7'
|
6
|
+
Options = Struct.new(
|
7
|
+
:template, :template_name, :is_html, :from, :subject,
|
8
|
+
:host, :port, :username, :password,
|
9
|
+
keyword_init: true
|
10
|
+
)
|
7
11
|
|
8
12
|
# It should take:
|
9
13
|
# * A list of emails and data
|
@@ -78,18 +82,19 @@ module Triklemailer
|
|
78
82
|
options.template_name)
|
79
83
|
rescue => e
|
80
84
|
puts "Failed to send email to #{recipient[:email]}."
|
85
|
+
puts e
|
81
86
|
next
|
82
87
|
end
|
83
88
|
end
|
84
89
|
end
|
85
90
|
|
86
|
-
def log_sent(email, template)
|
87
|
-
log_file_name = ['sent', template.split('.').first].join('_')
|
91
|
+
def self.log_sent(email, template)
|
92
|
+
log_file_name = "./#{['sent', template.split('.').first].join('_')}.csv"
|
88
93
|
|
89
94
|
CSV.open(
|
90
|
-
|
95
|
+
log_file_name,
|
91
96
|
'a',
|
92
|
-
write_headers:
|
97
|
+
write_headers: !File.exists?(log_file_name),
|
93
98
|
headers: ['email', 'sent_at']
|
94
99
|
) do |csv|
|
95
100
|
csv << [email, Time.now]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trikle-mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jasper Lyons
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Send bulk email in a trickle over mandrill
|
84
98
|
email: jasper.lyons@gmail.com
|
85
99
|
executables:
|