mailmerge 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +28 -4
- data/exe/mailmerge +2 -0
- data/lib/mailmerge.rb +28 -22
- data/lib/mailmerge/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b81dde605d612f8b14856af4d8e640247c49053f770b1ad90e2b66c7e680c57b
|
4
|
+
data.tar.gz: 399c2ce3463e2593d37c50b0ceaff767d66392a173b5e14f9cfa7ef86c9694d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49d86c206c1fafe1e7c98f3d54494e0e1d02ec16a4ef0ed91d8400ab22ec034eb84b6495a76d4d24997703428f2522d4af316947e87d774573b3c3e7344a2d3b
|
7
|
+
data.tar.gz: 5e2628d21e77457b558629314e4d8d3b5c5efecebc71c5fc5c0c81630e26c864f543f524e6c9b1dc35916a3a27990e721af9cb2c43d29491e6b7d68a9cc323c0
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Mailmerge
|
2
2
|
|
3
|
-
|
3
|
+
Mailmerge is a simple program that takes a list of template arguments in the form of a CSV file and populates an email template (in erb format) with those parameters.
|
4
4
|
|
5
|
-
|
5
|
+
You can use it to send a simple or formulaic email to multiple people and maintain some amount of personalization per person
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,7 +22,31 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
Example usage:
|
26
|
+
|
27
|
+
`mailmerge test.csv test.erb x@gmail.com password`
|
28
|
+
|
29
|
+
Example email template:
|
30
|
+
|
31
|
+
```
|
32
|
+
FROM: x@gmail.com
|
33
|
+
SUBJECT: <%= foo %>
|
34
|
+
TO: <%= @to_email %>
|
35
|
+
|
36
|
+
<%= bar %>
|
37
|
+
<%= baz %>
|
38
|
+
|
39
|
+
Regards,
|
40
|
+
Person
|
41
|
+
```
|
42
|
+
|
43
|
+
Example CSV:
|
44
|
+
|
45
|
+
```
|
46
|
+
to_email,foo,bar,baz
|
47
|
+
y@gmail.com,1,2,3
|
48
|
+
z@yahoo.com,4,5,6
|
49
|
+
```
|
26
50
|
|
27
51
|
## Development
|
28
52
|
|
@@ -32,7 +56,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
56
|
|
33
57
|
## Contributing
|
34
58
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/MatanSilver/mailmerge.
|
36
60
|
|
37
61
|
## License
|
38
62
|
|
data/exe/mailmerge
CHANGED
data/lib/mailmerge.rb
CHANGED
@@ -10,17 +10,6 @@ include Open3
|
|
10
10
|
|
11
11
|
module Mailmerge
|
12
12
|
class Error < StandardError; end
|
13
|
-
|
14
|
-
smtp = Net::SMTP.new 'smtp.gmail.com', 587
|
15
|
-
smtp.enable_starttls
|
16
|
-
arr_of_rows = CSV.read(ARGV[0])
|
17
|
-
email_template = ARGV[1]
|
18
|
-
headers = arr_of_rows[0]
|
19
|
-
rows = arr_of_rows[1..]
|
20
|
-
template_contents = File.read(ARGV[1])
|
21
|
-
user_email = ARGV[2]
|
22
|
-
user_password = ARGV[3]
|
23
|
-
|
24
13
|
class TemplateData < ERB
|
25
14
|
def initialize(keys, values, template)
|
26
15
|
@template = template
|
@@ -34,18 +23,35 @@ module Mailmerge
|
|
34
23
|
super(binding)
|
35
24
|
end
|
36
25
|
end
|
26
|
+
class Merger
|
27
|
+
def merge
|
28
|
+
if ARGV[0] == "-h"
|
29
|
+
puts "usage: mailmerge [csv] [erb] [from_addr] [password]"
|
30
|
+
exit
|
31
|
+
end
|
32
|
+
smtp = Net::SMTP.new 'smtp.gmail.com', 587
|
33
|
+
smtp.enable_starttls
|
34
|
+
arr_of_rows = CSV.read(ARGV[0])
|
35
|
+
email_template = ARGV[1]
|
36
|
+
headers = arr_of_rows[0]
|
37
|
+
rows = arr_of_rows[1..]
|
38
|
+
template_contents = File.read(ARGV[1])
|
39
|
+
user_email = ARGV[2]
|
40
|
+
user_password = ARGV[3]
|
37
41
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
renderer = ERB.new(template_contents)
|
43
|
+
rows.each do |row|
|
44
|
+
td = TemplateData.new(headers, row, template_contents)
|
45
|
+
rendered_email = td.result
|
46
|
+
puts rendered_email
|
47
|
+
smtp.start('gmail.com',
|
48
|
+
user_email, user_password, :plain) do |smtp|
|
49
|
+
smtp.send_message rendered_email,
|
50
|
+
user_email,
|
51
|
+
td.instance_variable_get("@to_email")
|
52
|
+
end
|
53
|
+
puts "-------------------------"
|
54
|
+
end
|
48
55
|
end
|
49
|
-
puts "-------------------------"
|
50
56
|
end
|
51
57
|
end
|
data/lib/mailmerge/version.rb
CHANGED