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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e47bd09ee5de38cd21b2c79250238d6f2ad4b44
4
- data.tar.gz: 7ed7221510a648c636f46271a15dbaa69f6664e6
3
+ metadata.gz: 8bcc21b195e0395f38e450e9d5090080259aaeef
4
+ data.tar.gz: 32cfeac3bd3ccd961548d683eb8fd94804f311f7
5
5
  SHA512:
6
- metadata.gz: 507b9231374792f493ea0e91a43db7ae24ecb2c99f235f47093e1ddfdcc7f410dff0b887000b4a6da3f96c7e8d6935a0b84d90bad293a7b76e3a3bbf74b3c63e
7
- data.tar.gz: c9443c75400f473855e466aabe2c6cd2b164f8b28988886d3e8a3607e8e4e1f7b695aa13a5b9a032a7faa4af8684544186a4fae76e0aadbeea72173b7ddced18
6
+ metadata.gz: fe442f4bac88abeb32a5c985953a11f979bca690db7c316386bdf3eac8dd8c45603bcab443c533307bd0608474156bced948a9043c266f7e9b363ea6a0410091
7
+ data.tar.gz: 99f7f05b5607aea13bc263953066cd58c6a1bac7d5ee949acc184036ebb5edba4c3e755a55b01dc14f78ee71483a585ceaaf55bbcd07ec2d3669630c1d282484
checksums.yaml.gz.sig CHANGED
Binary file
@@ -9,10 +9,11 @@ require 'fileutils'
9
9
 
10
10
  class MarkdownMailSender
11
11
 
12
- def initialize(user, password, compose_dir: '~/email/compose',
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
- do |msg_filepath|
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
- Net::SMTP.start(@smtp_host, 25, @mail_from_domain, @user,
99
- @password, :login) do |smtp|
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.0
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-06-23 00:00:00.000000000 Z
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