markdown_mail_sender 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
- checksums.yaml.gz.sig +0 -0
- data/lib/markdown_mail_sender.rb +14 -12
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bcc21b195e0395f38e450e9d5090080259aaeef
|
4
|
+
data.tar.gz: 32cfeac3bd3ccd961548d683eb8fd94804f311f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe442f4bac88abeb32a5c985953a11f979bca690db7c316386bdf3eac8dd8c45603bcab443c533307bd0608474156bced948a9043c266f7e9b363ea6a0410091
|
7
|
+
data.tar.gz: 99f7f05b5607aea13bc263953066cd58c6a1bac7d5ee949acc184036ebb5edba4c3e755a55b01dc14f78ee71483a585ceaaf55bbcd07ec2d3669630c1d282484
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/markdown_mail_sender.rb
CHANGED
@@ -9,10 +9,11 @@ require 'fileutils'
|
|
9
9
|
|
10
10
|
class MarkdownMailSender
|
11
11
|
|
12
|
-
def initialize(
|
12
|
+
def initialize(accounts={}, compose_dir: '~/email/compose',
|
13
13
|
sent_dir: '~/email/sent', smtp_host: nil, from_domain: smtp_host)
|
14
|
+
|
15
|
+
@accounts = accounts
|
14
16
|
|
15
|
-
@user, @password = user, password
|
16
17
|
@smtp_host, @mail_from_domain = smtp_host, from_domain
|
17
18
|
|
18
19
|
compose_dirpath = File.expand_path(compose_dir)
|
@@ -21,11 +22,10 @@ class MarkdownMailSender
|
|
21
22
|
|
22
23
|
# scan the compose directory for email files to deliver
|
23
24
|
|
24
|
-
@messages = Dir.glob(File.join(compose_dirpath, '*.md')).map
|
25
|
-
|
26
|
-
|
25
|
+
@messages = Dir.glob(File.join(compose_dirpath, '*.md')).map do |msg_filepath|
|
26
|
+
|
27
27
|
s = File.read msg_filepath
|
28
|
-
|
28
|
+
|
29
29
|
regex = %r{
|
30
30
|
|
31
31
|
(?<email>(?:.*<)?\w+(?:\.\w+)?@\S+>?){0}
|
@@ -40,7 +40,7 @@ class MarkdownMailSender
|
|
40
40
|
}xm =~ s
|
41
41
|
|
42
42
|
files = attachments.nil? ? [] : attachments.split.map(&:strip)
|
43
|
-
|
43
|
+
|
44
44
|
{
|
45
45
|
filepath: msg_filepath, from: from, to: to, attachments: files,
|
46
46
|
subject: subject, body_txt: body,
|
@@ -54,8 +54,6 @@ class MarkdownMailSender
|
|
54
54
|
def deliver_all()
|
55
55
|
|
56
56
|
@messages.each.with_index do |x, i|
|
57
|
-
|
58
|
-
puts 'xx: ' + x.inspect
|
59
57
|
|
60
58
|
raw_marker = "AUNIQUEMARKER"
|
61
59
|
marker = "\n--#{raw_marker}"
|
@@ -95,8 +93,12 @@ EOF
|
|
95
93
|
|
96
94
|
mailtext = a.join(marker + "\n") + marker + "--"
|
97
95
|
|
98
|
-
|
99
|
-
|
96
|
+
from = x[:from][/(?:.*<)?(\w+(?:\.\w+)?@\S+)>/,1]
|
97
|
+
|
98
|
+
user, password = from[/[^@]+/], @accounts[from]
|
99
|
+
|
100
|
+
Net::SMTP.start(@smtp_host, 25, @mail_from_domain, user,
|
101
|
+
password, :login) do |smtp|
|
100
102
|
|
101
103
|
smtp.send_message mailtext, from, to
|
102
104
|
|
@@ -133,4 +135,4 @@ EOF
|
|
133
135
|
|
134
136
|
end
|
135
137
|
|
136
|
-
end
|
138
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_mail_sender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
/lI2nqMMq5f39gxDkuM9dlpQCTSlNYaMUH/Ygfnaqi9j9ntJiW9/yjiYUGV7wzeS
|
32
32
|
h4yZiygx7MCysQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-
|
34
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rdiscount
|
metadata.gz.sig
CHANGED
Binary file
|