mail_alternatives_with_attachments 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjQ0NDQ3ZDY5M2RjZGJkOTRhZDA1ZWU2NTkwZDljNWVlZTU3OTUzOA==
5
+ data.tar.gz: !binary |-
6
+ N2FkMjJiNDM0NWY3ZjY4NjM2OTU5NDI3Y2Y1ZTM0ODRkYWM1NmM3OA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MjA3OTkwMTUxYjBlMjExMDgzYjMyMWI0ZjdiOTY4YTlkOWYyN2Y3NjgzZGE4
10
+ ODc3ZjZkNzQwMWFhZmYyMDc4ZTcyZjZiNjRhMmEyN2ZhNjM4NDZhZWU4MWMy
11
+ ZmNhYTc0MDc5NjVmNzlkYzljOWM0OTRmMDYzMzZhY2EzY2JlN2E=
12
+ data.tar.gz: !binary |-
13
+ YmNlZjkzZDY1MTU1NTU0MDEzY2VlYWU2ZDNmNjdlOWIyZTU3NzdlYTc5OTdk
14
+ OWJjODQ5M2U3NzNlZjY2MGU4YmI4YWEyOGJjNTk4ZTYxOWM5ODRiOThmNTlk
15
+ NDJmYTI5MjYyNTRjYmJkMTZjMTQ5NTdkNmRkNWJkODM5NTFjZDQ=
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 James Coleman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,7 +1,7 @@
1
1
  Why?
2
2
  ====
3
3
 
4
- Spam filters often require that an HTML email also have a Text alternative that is generally the same as the HTML message. This means you need to send an email with a MIME type of `multipart/alternative` containing `text/html` and `text/plain` parts. ActionMailer 3 supports this scenario, but it falls apart when you need to add (inline) attachments to that mix. The property MIME hierarchy for an email like this is:
4
+ Spam filters often require that an HTML email also have a text alternative that is generally the same as the HTML message. This means you need to send an email with a MIME type of `multipart/alternative` containing `text/html` and `text/plain` parts. ActionMailer 3 supports this scenario, but it falls apart when you need to add (inline) attachments to that mix. The proper MIME hierarchy for an email like this is:
5
5
 
6
6
  * `multipart/mixed`
7
7
  * `multipart/alternative`
@@ -13,13 +13,24 @@ Spam filters often require that an HTML email also have a Text alternative that
13
13
 
14
14
  If this seems more complicated then it should be, that's because it is. Thankfully, this gem allows you to create this entire hierarchy without all the hard work.
15
15
 
16
+ Installation:
17
+ =============
18
+
19
+ Either include
20
+
21
+ gem "mail_alternatives_with_attachments"
22
+
23
+ in your Gemfile (if using Bundler) or run
24
+
25
+ gem install mail_alternatives_with_attachments
26
+
16
27
  Usage:
17
28
  ======
18
29
 
19
30
  Including the `mail_alternatives_with_attachments` gem in your project will patch ActionMailer with the following two methods:
20
31
 
21
- * `ActionMailer::Base#prepare_message(headers={})`: This method does exactly what `ActionMailer::Base#mail(headers={})` does; however it doesn't automatically rendering of templates so that we add our own custom message parts.
22
- * `Mail::Message#alternative_content_types_with_attachment(options, &block)`: This method allows you to conveniently add all of the different parts of complex email with alternatives and attachments.
32
+ * `ActionMailer::Base#prepare_message(headers={})`: This method does exactly what `ActionMailer::Base#mail(headers={})` does; however it doesn't automatically render templates. This allows us to add our own custom message parts.
33
+ * `Mail::Message#alternative_content_types_with_attachment(options, &block)`: This method allows you to conveniently add all of the different parts of a complex email with alternatives and attachments.
23
34
 
24
35
  Typically when using ActionMailer 3, you would create a message with the following code:
25
36
 
@@ -31,7 +42,7 @@ Typically when using ActionMailer 3, you would create a message with the followi
31
42
  end
32
43
  end
33
44
 
34
- Using this gem to create an email with both alternatives and attachments you would use the following code:
45
+ To create an email with both alternatives and attachments you would use the following code:
35
46
 
36
47
  class MyEmailerClass < ActionMailer::Base
37
48
  def my_email_method(address, attachment, logo)
@@ -39,7 +50,7 @@ Using this gem to create an email with both alternatives and attachments you wou
39
50
 
40
51
  message.alternative_content_types_with_attachment(
41
52
  :text => render_to_string(:template => "my_template.text"),
42
- :html => render_to_string("my_template.html")
53
+ :html => render_to_string(:template => "my_template.html")
43
54
  ) do |inline_attachments|
44
55
  inline_attachments.inline['logo.png'] = logo
45
56
  end
@@ -2,19 +2,19 @@ module MailAlternativesWithAttachments::ActionMailerPrepareMessage
2
2
 
3
3
  # Copied directly from ActionMailer::Base#mail but without
4
4
  # the automatic rendering of templates.
5
- def prepare_message(headers={})
6
- # Guard flag to prevent both the old and the new API from firing
7
- # Should be removed when old API is removed
8
- @mail_was_called = true
5
+ def prepare_message(headers = {}, &block)
6
+ return @_message if @_mail_was_called && headers.blank? && !block
7
+
8
+ @_mail_was_called = true
9
9
  m = @_message
10
10
 
11
- # At the beginning, do not consider class default for parts order neither content_type
11
+ # At the beginning, do not consider class default for content_type
12
12
  content_type = headers[:content_type]
13
- parts_order = headers[:parts_order]
14
13
 
15
14
  # Call all the procs (if any)
16
- default_values = self.class.default.merge(self.class.default) do |k,v|
17
- v.respond_to?(:call) ? v.bind(self).call : v
15
+ default_values = {}
16
+ self.class.default.each do |k,v|
17
+ default_values[k] = v.is_a?(Proc) ? instance_eval(&v) : v
18
18
  end
19
19
 
20
20
  # Handle defaults
@@ -25,7 +25,7 @@ module MailAlternativesWithAttachments::ActionMailerPrepareMessage
25
25
  m.charset = charset = headers[:charset]
26
26
 
27
27
  # Set configure delivery behavior
28
- wrap_delivery_behavior!(headers.delete(:delivery_method))
28
+ wrap_delivery_behavior!(headers.delete(:delivery_method), headers.delete(:delivery_method_options))
29
29
 
30
30
  # Assign all headers except parts_order, content_type and body
31
31
  assignable = headers.except(:parts_order, :content_type, :body, :template_name, :template_path)
@@ -36,8 +36,7 @@ module MailAlternativesWithAttachments::ActionMailerPrepareMessage
36
36
  m.charset = charset
37
37
 
38
38
  if m.multipart?
39
- parts_order ||= headers[:parts_order]
40
- m.body.set_sort_order(parts_order)
39
+ m.body.set_sort_order(headers[:parts_order])
41
40
  m.body.sort_parts!
42
41
  end
43
42
 
@@ -1,3 +1,3 @@
1
1
  module MailAlternativesWithAttachments
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -12,8 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.description = %q{ActionMailer 3 makes it much easier to send emails, but there is one case it doesn't handle well.\
13
13
  Specifically, it is difficult to send a message that has the proper MIME hiearchy for an email with both HTML and text alternatives\
14
14
  that also includes attachments. This gem solves that need.}
15
-
16
- s.rubyforge_project = "mail_alternatives_with_attachments"
15
+ s.license = "MIT"
17
16
 
18
17
  s.files = `git ls-files`.split("\n")
19
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -23,4 +22,5 @@ Gem::Specification.new do |s|
23
22
  # specify any dependencies here; for example:
24
23
  # s.add_development_dependency "rspec"
25
24
  # s.add_runtime_dependency "rest-client"
25
+ s.add_runtime_dependency "actionmailer", "~> 4.0"
26
26
  end
metadata CHANGED
@@ -1,16 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail_alternatives_with_attachments
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - James Coleman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-12-24 00:00:00.000000000Z
13
- dependencies: []
11
+ date: 2014-04-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionmailer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
14
27
  description: ! "ActionMailer 3 makes it much easier to send emails, but there is one
15
28
  case it doesn't handle well.\\\n Specifically, it is difficult to send a message
16
29
  that has the proper MIME hiearchy for an email with both HTML and text alternatives\\\n
@@ -23,6 +36,7 @@ extra_rdoc_files: []
23
36
  files:
24
37
  - .gitignore
25
38
  - Gemfile
39
+ - LICENSE.txt
26
40
  - README.markdown
27
41
  - Rakefile
28
42
  - lib/mail_alternatives_with_attachments.rb
@@ -31,28 +45,28 @@ files:
31
45
  - lib/mail_alternatives_with_attachments/version.rb
32
46
  - mail_alternatives_with_attachments.gemspec
33
47
  homepage: https://github.com/jcoleman/mail_alternatives_with_attachments
34
- licenses: []
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
35
51
  post_install_message:
36
52
  rdoc_options: []
37
53
  require_paths:
38
54
  - lib
39
55
  required_ruby_version: !ruby/object:Gem::Requirement
40
- none: false
41
56
  requirements:
42
57
  - - ! '>='
43
58
  - !ruby/object:Gem::Version
44
59
  version: '0'
45
60
  required_rubygems_version: !ruby/object:Gem::Requirement
46
- none: false
47
61
  requirements:
48
62
  - - ! '>='
49
63
  - !ruby/object:Gem::Version
50
64
  version: '0'
51
65
  requirements: []
52
- rubyforge_project: mail_alternatives_with_attachments
53
- rubygems_version: 1.8.10
66
+ rubyforge_project:
67
+ rubygems_version: 2.1.5
54
68
  signing_key:
55
- specification_version: 3
69
+ specification_version: 4
56
70
  summary: This gem makes it easy to send multipart alternative emails from ActionMailer
57
71
  3
58
72
  test_files: []