minimail 0.0.5 → 0.0.6
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.
- data/lib/minimail/mail.rb +4 -3
- data/lib/minimail/version.rb +1 -1
- data/readme.md +11 -15
- data/test/minimail_test.rb +7 -1
- metadata +4 -4
data/lib/minimail/mail.rb
CHANGED
@@ -21,12 +21,13 @@ module Minimail
|
|
21
21
|
@recipients = recipients
|
22
22
|
end
|
23
23
|
|
24
|
-
def body(body =
|
24
|
+
def body(body = '')
|
25
25
|
@body = body
|
26
26
|
end
|
27
27
|
|
28
28
|
def deliver
|
29
|
-
return unless valid?
|
29
|
+
return "Invalid mail contents" unless valid?
|
30
|
+
return "Invalid mail command" unless mail_command
|
30
31
|
if @attachments
|
31
32
|
IO.popen("(#{@attachments}) | #{mail_command} -s '#{@subject}' #{@recipients}", "w") do |io|
|
32
33
|
io.write @body
|
@@ -75,4 +76,4 @@ module Minimail
|
|
75
76
|
end
|
76
77
|
|
77
78
|
end
|
78
|
-
end
|
79
|
+
end
|
data/lib/minimail/version.rb
CHANGED
data/readme.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
Minimail sends emails
|
1
|
+
Minimail sends emails (using `mail` with attachments using `uuencode`).
|
2
2
|
|
3
3
|
Installation
|
4
4
|
=========
|
5
5
|
|
6
6
|
With bundler
|
7
7
|
------------
|
8
|
-
|
9
|
-
# gem install bundler
|
8
|
+
|
10
9
|
gem 'minimail'
|
11
10
|
bundle
|
12
11
|
|
@@ -18,10 +17,10 @@ Without bundler
|
|
18
17
|
Usage
|
19
18
|
=====
|
20
19
|
|
21
|
-
# Send an email
|
22
|
-
Minimail::Mail.new(:subject => "
|
20
|
+
# Send an email in one line
|
21
|
+
Minimail::Mail.new(:subject => "[app] Background job is complete", :recipients => "engineer@example.com").deliver
|
23
22
|
|
24
|
-
# Or
|
23
|
+
# Or use a DSL style
|
25
24
|
m = Minimail::Mail.new
|
26
25
|
m.draft do
|
27
26
|
subject "check it!"
|
@@ -29,24 +28,21 @@ Usage
|
|
29
28
|
end
|
30
29
|
m.deliver
|
31
30
|
|
32
|
-
#
|
33
|
-
Minimail::Mail.new(:subject => "
|
31
|
+
# Add an attachment
|
32
|
+
Minimail::Mail.new(:subject => "[app] Success", :recipients => "engineer@example.com", :attachments => File.join(Dir.pwd, 'test', 'fake_attachment.txt')).deliver
|
34
33
|
|
35
34
|
Run tests
|
36
35
|
=========
|
37
36
|
|
38
|
-
#
|
39
|
-
|
40
|
-
rake # as of this writing: 6 tests, 11 assertions, 0 failures, 0 errors, 0 skips
|
37
|
+
# With RVM, `rvm use 1.8.7 && rvm gemset create minimail && rvm gemset use minimail`
|
38
|
+
rake
|
41
39
|
|
42
40
|
Debugging
|
43
41
|
=========
|
44
|
-
Some ISPs will block the SMTP port or black-list IP addresses. I was not able to send on a Verizon
|
45
|
-
but was able to send using my cellular 3G connection (also Verizon) while tethered.
|
42
|
+
Some ISPs will block the SMTP port or black-list IP addresses. I was not able to send on a Verizon connection at home, but was able to send using cellular connections (AT&T and Verizon) while tethered.
|
46
43
|
|
47
|
-
|
44
|
+
With gmail, the test mails show up in the spam folder. To check your mail log file on OS X:
|
48
45
|
|
49
|
-
# on OS X tail the mail log file
|
50
46
|
tail -f /var/log/mail.log
|
51
47
|
|
52
48
|
Credits
|
data/test/minimail_test.rb
CHANGED
@@ -41,8 +41,8 @@ class Minimail::MailTest < MiniTest::Unit::TestCase
|
|
41
41
|
|
42
42
|
def test_ensure_mail_is_not_valid_unless_recipient_is_specified
|
43
43
|
mail = Minimail::Mail.new()
|
44
|
-
assert_nil mail.deliver
|
45
44
|
assert !mail.valid?
|
45
|
+
assert_equal "Invalid mail contents", mail.deliver
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_can_create_a_minimail_with_dsl_style
|
@@ -56,4 +56,10 @@ class Minimail::MailTest < MiniTest::Unit::TestCase
|
|
56
56
|
assert_equal "bob@example.com", m.instance_variable_get(:@recipients)
|
57
57
|
assert_equal "cool stuff", m.instance_variable_get(:@body)
|
58
58
|
end
|
59
|
+
|
60
|
+
def test_mail_has_empty_string_body_if_none_provided
|
61
|
+
recipients = "jane@example.com"
|
62
|
+
mail = Minimail::Mail.new(:recipients => recipients)
|
63
|
+
assert_equal '', mail.body
|
64
|
+
end
|
59
65
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minimail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Atkinson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-07-23 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|