smitty 0.0.5 → 1.0.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.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YWE1ZDZmNGM5NmIwMWJlMjE4YjUyNDY1ODE2MzVhOTRlZTdkNGUxYQ==
5
- data.tar.gz: !binary |-
6
- NDIxOGZlNmNjNTRkNGEwMjA0NGFhOTMwODAzOWYwNTdlMjAwYzM3Yw==
2
+ SHA1:
3
+ metadata.gz: 99a212ff5d842c723fc6c7065735ea067f36d3ce
4
+ data.tar.gz: 5b32ed4266e57f252b2d1216789802922fa5b30b
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NTFlODBiYjUxYTRmZDU0Y2FhMzdlNzkxMGExYmVmZGExNGViMTU1N2JmZWNk
10
- ODkxOWY0ODNhZDQwN2U1OWU4NzU0OGIzOTM4ZTk5ZDQwMzM1OTRjMTgyNzU2
11
- M2VlNjA3YmNhOTI3MDMzYzFiMzI2MTBlMmZiN2NiODk4NTk2ZTA=
12
- data.tar.gz: !binary |-
13
- ZDI0M2UyY2Q4MTEzYzc4ODg1Y2RiMWZjZTliMDkxZWNlODNmM2Y4ZDQ4YzIy
14
- MjE0ZWNjMjZiODRiM2YyNDBlOTRmMjk2YTYzNmYzZDE3MGQ2NjE1MzIwZDEx
15
- Mzc3NWIzMzY5YWIxNGQzZDIyMDM4ZjNhNzJkYjY1MzM0OTk5OTY=
6
+ metadata.gz: 23ce6b70ed7750b1d2de87156f77fa527417b29b5a3f787312d23473d6a16b236a1867b0dbddc46eea2fd3c25a71b3bdb2ac580b0996eb23029b59f51fff9a16
7
+ data.tar.gz: a5b08ff840a51a341e6f6657659d040f0274bd6fcc4f4a0c3a4f0f8a755f7e4e9159f7e92cc6db9bad44c0fc89f180e63750f476aee6c6851c99935862ef9b98
data/README.md CHANGED
@@ -10,6 +10,14 @@ For example, say you wanted to loop over a set of emails and names, inserting a
10
10
 
11
11
  Smitty would then loop over each email address in emails.txt, replacing {{name}} with the corresponding name from names.txt. As you can see, variable names in the subject is also supported.
12
12
 
13
+ ## Content-ID Embedded Images
14
+
15
+ Smitty includes the ability to generate Content-ID values for attached images and embed the content within the handlebars HTML template in accordance with [RFC2557](http://tools.ietf.org/html/rfc2557#page-8). Smitty will generate a Multi-Part email message and search the handlebar HTML template for image references associated with the attached image name.
16
+
17
+ ./smitty from@someplace.io emails.txt 'Subject' -a someimage.jpg --cid tempalte.hbs
18
+
19
+ Smitty will then search through the template and replace references to \<img src="cid:{{someimage.jpg}}"\> with the Content-ID value of the attached image.
20
+
13
21
  ## Installation
14
22
 
15
23
  $ gem install smitty
@@ -21,12 +29,12 @@ Or build and install it yourself as:
21
29
 
22
30
  ## Usage
23
31
 
24
- Smitty 0.0.4
32
+ Smitty 1.0.0
25
33
 
26
34
  Usage:
27
- ./smitty [options] <from_address> <to_file> <subject> <template>
28
- ./smitty -h | --help
29
- ./smitty -v | --version
35
+ smitty [options] <from_address> <to_file> <subject> <template>
36
+ smitty -h | --help
37
+ smitty -v | --version
30
38
 
31
39
  Required Arguments:
32
40
  from_address: Address to send mail from.
@@ -42,6 +50,7 @@ Or build and install it yourself as:
42
50
  template, and value may be a constant or a newline separated file.
43
51
  Value file and to_file must have the same amount of lines.
44
52
  -a files Attach comma separated list of files.
53
+ --cid Enable CID embedding of images for email attachments, default is false.
45
54
  --server SERVER SMTP Server, default is localhost.
46
55
  --port PORT SMTP Port, default is 25.
47
56
  --ssl Use SSL, default is false.
@@ -50,6 +59,7 @@ Or build and install it yourself as:
50
59
  --cc address Add a cc address.
51
60
  --bcc address Add a bcc address.
52
61
  --messageid FQDN Set a FQDN to use when generating the message-id for each message.
62
+ --sleep SEC Sets sleep delay, in seconds, per each recipent.
53
63
  --dry-run Output messages and don't send.
54
64
 
55
65
  ## Contributing
data/bin/smitty CHANGED
@@ -23,9 +23,11 @@ end
23
23
 
24
24
  attachments = args['-a'].split(',') if args['-a']
25
25
  from_address = args['<from_address>']
26
+ match_address = /[-0-9a-z.+_]+@[-0-9a-z.+_]+\.[a-z]{2,}/i.match(from_address).to_s
26
27
  subject = args['<subject>']
27
- message_id_fqdn = from_address.split('@')[1]
28
+ message_id_fqdn = match_address.split('@')[1]
28
29
  message_id_fqdn = args['-messageid'] if args['-messageid']
30
+ sleep = args['--sleep'] unless args['--sleep'].nil?
29
31
 
30
32
  # Read to_file into list of addresses
31
33
  begin
@@ -81,7 +83,15 @@ to_addresses.each do |to_address|
81
83
  end
82
84
  # Attach each file to the message
83
85
  begin
84
- attachments.each { |file| mail.add_file(file) } unless attachments.nil?
86
+ attachments.each { |file|
87
+ mail.add_file(file)
88
+ if args['--cid']
89
+ file.sub!(/.*?\/(\w+\.\w{3})$/, '\1')
90
+ image = mail.attachments[file]
91
+ template_copy.gsub!("{{#{file}}}", image.cid)
92
+ subject_copy.gsub!("{{#{file}}}", image.cid)
93
+ end
94
+ } unless attachments.nil?
85
95
  rescue Exception => e
86
96
  Smitty.croak('Could not attach file', e.message)
87
97
  end
@@ -92,6 +102,10 @@ to_addresses.each do |to_address|
92
102
  begin
93
103
  mail.deliver!
94
104
  puts "Message sent"
105
+ if defined?(sleep) && !to_address.equal?(to_addresses.last)
106
+ puts "Sleeping for #{sleep} seconds"
107
+ sleep(sleep.to_i)
108
+ end
95
109
  rescue Exception => e
96
110
  puts "Error: #{e.message}"
97
111
  end
@@ -6,10 +6,14 @@ module Smitty
6
6
  smtp_server = server.nil? ? 'localhost' : server
7
7
  smtp_port = port.nil? ? 25 : port.to_i
8
8
  smtp_conn = Net::SMTP.new(smtp_server, smtp_port)
9
- smtp_conn.enable_tls() if ssl
9
+ smtp_conn.enable_starttls() if ssl
10
10
  if username
11
11
  Smitty.croak('No password provided') if password.nil?
12
- smtp_conn.start(smtp_server, username, password, :plain)
12
+ if ssl
13
+ smtp_conn.start(smtp_server, username, password, :login)
14
+ else
15
+ smtp_conn.start(smtp_server, username, password, :plain)
16
+ end
13
17
  else
14
18
  smtp_conn.start()
15
19
  end
@@ -21,6 +21,7 @@ Options:
21
21
  template, and value may be a constant or a newline separated file.
22
22
  Value file and to_file must have the same amount of lines.
23
23
  -a files Attach comma separated list of files.
24
+ --cid Enable CID embedding of images for email attachments, default is false.
24
25
  --server SERVER SMTP Server, default is localhost.
25
26
  --port PORT SMTP Port, default is 25.
26
27
  --ssl Use SSL, default is false.
@@ -29,7 +30,8 @@ Options:
29
30
  --cc address Add a cc address.
30
31
  --bcc address Add a bcc address.
31
32
  --messageid FQDN Set a FQDN to use when generating the message-id for each message.
33
+ --sleep SEC Sets sleep delay, in seconds, per each recipent.
32
34
  --dry-run Output messages and don't send.
33
35
 
34
36
  DOC
35
- end
37
+ end
@@ -12,4 +12,4 @@ module Smitty
12
12
  end
13
13
  {replace_string: pairs[0], with: with_content }
14
14
  end
15
- end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Smitty
2
- VERSION = '0.0.5'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smitty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Steele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-19 00:00:00.000000000 Z
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.5.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.5.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.6.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.6.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mail
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.5.4
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.5.4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: premailer
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.7.3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.7.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: Send mail with handlebars like templates
@@ -102,7 +102,7 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
- - .gitignore
105
+ - ".gitignore"
106
106
  - Gemfile
107
107
  - LICENSE.txt
108
108
  - README.md
@@ -125,17 +125,17 @@ require_paths:
125
125
  - lib
126
126
  required_ruby_version: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - ! '>='
128
+ - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  requirements:
133
- - - ! '>='
133
+ - - ">="
134
134
  - !ruby/object:Gem::Version
135
135
  version: '0'
136
136
  requirements: []
137
137
  rubyforge_project:
138
- rubygems_version: 2.2.2
138
+ rubygems_version: 2.4.5
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Send mail with handlebars like templates