simple_mailer 1.1.1 → 1.2.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0c29f8a54328df163579bbc2a52d4c88c700e2e8
4
+ data.tar.gz: e7d81522d9e9059d860510eb2449a053e699cc1e
5
+ SHA512:
6
+ metadata.gz: 9cc1a9501b92907e8a4a0b2fbf41c1a74ff3b01fed4d79da2009ea4582ba8609df215e55c1d30fea6a1d7b86a804e18c24666d5e9f9caa55bbbf345bc7283814
7
+ data.tar.gz: 18cf8b2af821be2c7573ddd84a91a1128e35372e2a8d9f8cb69be9ffbe399cb3fc027ea554f452ca86a4996b48d65381bdc69eb99aa2843d10baabd66b4ccdbd
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Jeremy Evans <code@jeremyevans.net>
1
+ Copyright (c) 2009,2013 Jeremy Evans <code@jeremyevans.net>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README CHANGED
@@ -14,8 +14,6 @@ simple_mailer can be installed with:
14
14
  Source is available at github:
15
15
  http://github.com/jeremyevans/simple_mailer
16
16
 
17
- RDoc is available at: http://code.jeremyevans.net/doc/simple_mailer/
18
-
19
17
  == Usage
20
18
 
21
19
  There is no required configuration, you can use simple_mailer
@@ -42,6 +40,21 @@ Or, you can include the SimpleMailer module in other classes:
42
40
  end
43
41
  Mailer.new('Subject', 'Body').email('from@from.com', 'to@to.com')
44
42
 
43
+ == Special Headers
44
+
45
+ There are four special headers that simple_mailer processes:
46
+
47
+ :smtp_to :: Override the actual SMTP recipients without modifying
48
+ the message.
49
+ :smtp_from :: Override the actual STMP sender without modifying
50
+ the message.
51
+ :cc :: Add a recipient to the message and include a CC header
52
+ with that recipient.
53
+ :bcc :: Add an recipient to the message without including that
54
+ information in the message headers.
55
+
56
+ All other headers are used verbatim in the message.
57
+
45
58
  == Testing
46
59
 
47
60
  Testing support is probably the main reason to use simple_mailer over
data/lib/simple_mailer.rb CHANGED
@@ -62,8 +62,17 @@ module SimpleMailer
62
62
  # headers do not have an carriage returns or line endings. Otherwise,
63
63
  # it's possible to inject arbitrary headers or body content.
64
64
  def send_email(from, to, subject, message, headers={})
65
+ headers = headers.dup
65
66
  smtp_from = headers.delete(:smtp_from) || from
66
67
  smtp_to = headers.delete(:smtp_to) || to
68
+ if cc = headers.delete(:cc)
69
+ headers['CC'] = cc
70
+ smtp_to = Array(smtp_to) + Array(cc)
71
+ end
72
+ if bcc = headers.delete(:bcc)
73
+ smtp_to = Array(smtp_to) + Array(bcc)
74
+ end
75
+
67
76
  to = to.join(", ") if to.is_a?(Array)
68
77
  _send_email(<<END_OF_MESSAGE, smtp_from, smtp_to)
69
78
  From: #{from}
@@ -47,6 +47,29 @@ Test Body 2
47
47
  END_MESSAGE
48
48
  end
49
49
 
50
+ it "should recognize the special :cc header" do
51
+ @mailer.send_email('from3@from.com', 'to3@to.com', 'Test Subject 3', 'Test Body 3', :cc=>'cc3@to.com')
52
+ $message.should == [<<END_MESSAGE, 'from3@from.com', ['to3@to.com', 'cc3@to.com'], 'localhost']
53
+ From: from3@from.com
54
+ To: to3@to.com
55
+ Subject: Test Subject 3
56
+ CC: cc3@to.com
57
+
58
+ Test Body 3
59
+ END_MESSAGE
60
+ end
61
+
62
+ it "should recognize the special :bcc header" do
63
+ @mailer.send_email('from3@from.com', 'to3@to.com', 'Test Subject 3', 'Test Body 3', :bcc=>'cc3@to.com')
64
+ $message.should == [<<END_MESSAGE, 'from3@from.com', ['to3@to.com', 'cc3@to.com'], 'localhost']
65
+ From: from3@from.com
66
+ To: to3@to.com
67
+ Subject: Test Subject 3
68
+
69
+ Test Body 3
70
+ END_MESSAGE
71
+ end
72
+
50
73
  it "should recognize the special :smtp_from and :smtp_to headers" do
51
74
  @mailer.send_email('from3@from.com', 'to3@to.com', 'Test Subject 3', 'Test Body 3', 'HeaderKey3'=>'HeaderValue3', :smtp_from=>'from@to.com', :smtp_to=>'to@from.com')
52
75
  $message.should == [<<END_MESSAGE, 'from@to.com', 'to@from.com', 'localhost']
@@ -59,6 +82,12 @@ Test Body 3
59
82
  END_MESSAGE
60
83
  end
61
84
 
85
+ it "should not modify input hash" do
86
+ h = {:smtp_to=>'to@to.com'}
87
+ @mailer.send_email('from3@from.com', 'to3@to.com', 'Test Subject 3', 'Test Body 3', h)
88
+ h.should == {:smtp_to=>'to@to.com'}
89
+ end
90
+
62
91
  it "should allow the setting of smtp server" do
63
92
  @mailer.smtp_server = 'blah.com'
64
93
  @mailer.send_email('from1@from.com', 'to1@to.com', 'Test Subject 1', 'Test Body 1')
metadata CHANGED
@@ -1,61 +1,51 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: simple_mailer
3
- version: !ruby/object:Gem::Version
4
- version: 1.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2009-12-30 00:00:00 -08:00
13
- default_executable:
11
+ date: 2013-05-20 00:00:00.000000000 Z
14
12
  dependencies: []
15
-
16
13
  description:
17
14
  email: code@jeremyevans.net
18
15
  executables: []
19
-
20
16
  extensions: []
21
-
22
- extra_rdoc_files:
23
- - LICENSE
24
- files:
17
+ extra_rdoc_files:
18
+ - MIT-LICENSE
19
+ files:
25
20
  - README
26
- - LICENSE
21
+ - MIT-LICENSE
27
22
  - lib/simple_mailer.rb
28
23
  - spec/simple_mailer.rb
29
- has_rdoc: true
30
24
  homepage:
31
25
  licenses: []
32
-
26
+ metadata: {}
33
27
  post_install_message:
34
- rdoc_options:
28
+ rdoc_options:
35
29
  - --inline-source
36
30
  - --line-numbers
37
31
  - README
38
32
  - lib
39
- require_paths:
33
+ require_paths:
40
34
  - lib
41
- required_ruby_version: !ruby/object:Gem::Requirement
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
46
- version:
47
- required_rubygems_version: !ruby/object:Gem::Requirement
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- version: "0"
52
- version:
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
53
45
  requirements: []
54
-
55
46
  rubyforge_project:
56
- rubygems_version: 1.3.5
47
+ rubygems_version: 2.0.2
57
48
  signing_key:
58
- specification_version: 3
49
+ specification_version: 4
59
50
  summary: Simple email library with testing support
60
51
  test_files: []
61
-