postmark-rails 0.4.2 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,7 +1,22 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.8.7"
4
- - "1.9.2"
5
- - "1.9.3"
6
- - "2.0.0"
7
- script: bundle exec rake spec
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - 2.0.0
7
+ script: bundle exec rake spec
8
+ gemfile:
9
+ - Gemfile
10
+ - gemfiles/Gemfile.actionmailer-3.0.x
11
+ - gemfiles/Gemfile.actionmailer-3.2.x
12
+ - gemfiles/Gemfile.actionmailer-4.0.x
13
+ matrix:
14
+ exclude:
15
+ - rvm: 1.8.7
16
+ gemfile: Gemfile
17
+ - rvm: 1.8.7
18
+ gemfile: gemfiles/Gemfile.actionmailer-4.0.x
19
+ - rvm: 1.9.2
20
+ gemfile: Gemfile
21
+ - rvm: 1.9.2
22
+ gemfile: gemfiles/Gemfile.actionmailer-4.0.x
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,25 @@
1
1
  = Changelog
2
2
 
3
+ == 0.5.1
4
+
5
+ * Upgraded actionmailer dependency to use >= 3.0.0.
6
+ * Added multiple gemfiles to test against multiple actionmailer versions (currently 3.0.x, 3.2.x, 4.0.x).
7
+
8
+ == 0.5.0
9
+
10
+ * Added integration specs.
11
+ * Updated the postmark gem dependency to 1.0.x.
12
+ * Removed attachments fix.
13
+ * Replaced README.rdoc with README.md.
14
+ * Added unit and integration tests for messages with attachemtns.
15
+ * Added batch delivery support.
16
+
17
+ == 0.4.2
18
+
19
+ * Updated the gem’s environment.
20
+ * Fixed the postmark gem dependency on 0.9.x.
21
+ * Added Travis-CI for integration testing.
22
+
3
23
  == 0.4.1
4
24
 
5
25
  * Fixed "returning" deprecation warning.
data/Gemfile CHANGED
@@ -1,3 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ group :test do
6
+ gem 'rspec', '~> 2.13.0'
7
+ end
data/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # postmark-rails gem
2
+
3
+ [![Build Status](https://travis-ci.org/wildbit/postmark-rails.png?branch=master)](https://travis-ci.org/wildbit/postmark-rails) [![Code Climate](https://codeclimate.com/github/wildbit/postmark-rails.png)](https://codeclimate.com/github/wildbit/postmark-rails)
4
+
5
+ The Postmark Rails Gem is a drop-in plug-in for ActionMailer to send emails via [Postmark](https://postmarkapp.com), an email delivery service for web apps. The gem has been created for fast implementation and fully supports all of [Postmark’s features](https://postmarkapp.com/why-postmark).
6
+
7
+ ## Supported Rails Versions
8
+
9
+ * Rails 4.0
10
+ * Rails 3.x
11
+
12
+ For Rails 2.3 please take a look at [version 0.4](https://github.com/wildbit/postmark-rails/tree/v0.4.2). It may miss some new features, but receives all required bug fixes and other support if needed.
13
+
14
+ ## Configuring your Rails application
15
+
16
+ Add this to your Gemfile: (change version numbers if needed)
17
+
18
+ ``` ruby
19
+ gem 'postmark-rails', '~> 0.5.1'
20
+ ```
21
+
22
+ Don’t forget to run `bundle install` command every time you change something in the Gemfile.
23
+
24
+ Add this to your config/application.rb:
25
+
26
+ ``` ruby
27
+ config.action_mailer.delivery_method = :postmark
28
+ config.action_mailer.postmark_settings = { :api_key => "your-api-key" }
29
+ ```
30
+
31
+ For the API details, refer to the [developer documentation](http://developer.postmarkapp.com).
32
+
33
+ ## Tagging your deliveries
34
+
35
+ You can use tags to categorize outgoing messages and attach application-specific information. Tagging the different types of email that you send lets you [review statistics and bounce reports separately](http://developer.postmarkapp.com/developer-build.html#message-format).
36
+
37
+ ``` ruby
38
+ class TestMailer < ActionMailer::Base
39
+
40
+ def tagged_message
41
+ mail(
42
+ :subject => 'hello',
43
+ :to => 'sheldon@bigbangtheory.com',
44
+ :from => 'leonard@bigbangtheory.com',
45
+ :tag => 'my-tag'
46
+ )
47
+ end
48
+
49
+ end
50
+ ```
51
+
52
+ ## Sending attachments
53
+
54
+ You can also send file attachments with Postmark. Read our Developer docs for [additional information](http://developer.postmarkapp.com/developer-build.html#attachments).
55
+
56
+ The Postmark gem is compatible with [ActionMailer attachments API](http://api.rubyonrails.org/classes/ActionMailer/Base.html#method-i-attachments). It allows you to specify the name, content-type and other attributes for your attachments.
57
+
58
+ The legacy `:postmark_attachments` attribute is *no longer supported* on Rails 3.2.13 and above.
59
+
60
+
61
+ ``` ruby
62
+ class TestMailer < ActionMailer::Base
63
+
64
+ def message_with_attachment
65
+ attachments['42.jpg'] = File.read("/path/to/file")
66
+ mail(
67
+ :subject => 'hello',
68
+ :to => 'sheldon@bigbangtheory.com',
69
+ :from => 'leonard@bigbangtheory.com'
70
+ )
71
+ end
72
+
73
+ end
74
+ ```
75
+
76
+ ## Sending in batches
77
+
78
+ While Postmark is focused on transactional email, we understand that developers
79
+ with higher volumes or processing time constraints need to send their messages
80
+ in batches. To facilitate this we provide a batching endpoint that permits you
81
+ to send up to 500 well-formed Postmark messages in a single API call.
82
+
83
+ ``` ruby
84
+ client = Postmark::ApiClient.new('your-api-key')
85
+
86
+ messages = []
87
+ messages << DigestMailer.weekly_digest(@user1)
88
+ messages << DigestMailer.weekly_digest(@user2)
89
+
90
+ client.deliver_messages(messages)
91
+
92
+ messages.first.delivered?
93
+ # => true
94
+
95
+ messages.all?(&:delivered)
96
+ # => true
97
+ ```
98
+
99
+ ## Additional information
100
+
101
+ Looking for the advanced usage examples? Check out [the documentation](https://github.com/wildbit/postmark-gem/blob/master/README.md) for the `postmark` gem. The `postmark-rails` gem is built on top of it, so you can benefit from all its features.
102
+
103
+ ## Requirements
104
+
105
+ * `postmark` gem version 1.0 and higher is required.
106
+ * You will also need a Postmark account, a server and at least one sender signature set up to use it. To get an account, [sign up](https://postmarkapp.com/sign_up)!.
107
+
108
+
109
+ ## Note on Patches/Pull Requests
110
+
111
+ * Fork the project.
112
+ * Make your feature addition or bug fix.
113
+ * Add tests for it. This is important so we don’t break it in a future version unintentionally.
114
+ * Commit, do not mess with rakefile, version, or history.
115
+ * Send a pull request. Bonus points for topic branches.
116
+
117
+ ## Authors & Contributors
118
+
119
+ * Artem Chistyakov
120
+ * Petyo Ivanov
121
+ * Ilya Sabanin
122
+ * Hristo Deshev
123
+ * Randy Schmidt
124
+ * Chris Williams
125
+ * Nicolás Sanguinetti
126
+ * Laust Rud Jacobsen (rud)
127
+
128
+ ## Copyright
129
+
130
+ Copyright © 2010—2013 Wildbit LLC. See LICENSE for details.
data/Rakefile CHANGED
@@ -3,8 +3,8 @@ Bundler::GemHelper.install_tasks
3
3
  require 'rake'
4
4
 
5
5
  require "rspec/core/rake_task"
6
+
6
7
  RSpec::Core::RakeTask.new(:spec) do |spec|
7
- spec.pattern = 'spec/*_spec.rb'
8
8
  spec.rspec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
9
9
  end
10
10
 
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'postmark', '~> 1.0.0'
4
+ gem 'actionmailer', '~> 3.0.0'
5
+
6
+ group :test do
7
+ gem 'rspec', '~> 2.13.0'
8
+ end
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'postmark', '~> 1.0.0'
4
+ gem 'actionmailer', '~> 3.2.0'
5
+
6
+ group :test do
7
+ gem 'rspec', '~> 2.13.0'
8
+ end
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'postmark', '~> 1.0.0'
4
+ gem 'actionmailer', '~> 4.0.0'
5
+
6
+ group :test do
7
+ gem 'rspec', '~> 2.13.0'
8
+ end
@@ -4,24 +4,23 @@ require 'postmark_delivery_method'
4
4
 
5
5
  module PostmarkInstaller
6
6
  extend self
7
-
7
+
8
8
  def auto_detect_and_install
9
9
  if ActionMailer::Base.respond_to?(:add_delivery_method)
10
- install_in_rails_3
10
+ install_in_rails
11
11
  else
12
- install_in_rails_2
12
+ install_in_legacy_rails
13
13
  end
14
14
  end
15
-
16
- def install_in_rails_2
15
+
16
+ def install_in_legacy_rails
17
17
  ActionMailer::Base.send(:include, PostmarkDeliveryMethod)
18
18
  end
19
-
20
- def install_in_rails_3
19
+
20
+ def install_in_rails
21
21
  ActionMailer::Base.add_delivery_method :postmark, Mail::Postmark, :api_key => nil
22
- Mail::Message.send(:include, Postmark::AttachmentsFixForMail)
23
22
  end
24
-
23
+
25
24
  end
26
25
 
27
26
  PostmarkInstaller.auto_detect_and_install
@@ -1,5 +1,5 @@
1
1
  module Postmark
2
2
  module Rails
3
- VERSION = '0.4.2'
3
+ VERSION = '0.5.1'
4
4
  end
5
5
  end
@@ -5,7 +5,6 @@ Gem::Specification.new do |s|
5
5
  s.name = %q{postmark-rails}
6
6
  s.version = Postmark::Rails::VERSION
7
7
  s.authors = ["Petyo Ivanov", "Ilya Sabanin", "Artem Chistyakov"]
8
- s.date = %q{2010-11-22}
9
8
  s.description = %q{Use this plugin in your rails applications to send emails through the Postmark API}
10
9
  s.email = %q{ilya@wildbit.com}
11
10
  s.homepage = %q{http://postmarkapp.com}
@@ -14,20 +13,19 @@ Gem::Specification.new do |s|
14
13
  s.post_install_message = %q{
15
14
  ==================
16
15
  Thanks for installing the postmark-rails gem. If you don't have an account, please sign up at http://postmarkapp.com/.
17
- Review the README.rdoc for implementation details and examples.
16
+ Review the README.md for implementation details and examples.
18
17
  ==================
19
18
  }
20
19
 
21
20
  s.extra_rdoc_files = [
22
21
  "LICENSE",
23
- "README.rdoc"
22
+ "README.md"
24
23
  ]
25
24
  s.rdoc_options = ["--charset=UTF-8"]
26
25
 
27
- s.add_dependency('actionmailer')
28
- s.add_dependency('postmark', "~> 0.9")
26
+ s.add_dependency('actionmailer', ">= 3.0.0")
27
+ s.add_dependency('postmark', "~> 1.0")
29
28
  s.add_development_dependency('rake')
30
- s.add_development_dependency('rspec', '>= 2.7.0')
31
29
 
32
30
  s.files = `git ls-files`.split("\n")
33
31
  s.test_files = `git ls-files -- spec/*`.split("\n")
Binary file
@@ -1,8 +1,8 @@
1
1
  class TestMailer < ActionMailer::Base
2
- default :subject => 'hello',
3
- :to => 'sheldon@bigbangtheory.com',
2
+ default :subject => 'hello',
3
+ :to => 'sheldon@bigbangtheory.com',
4
4
  :from => 'leonard@bigbangtheory.com'
5
-
5
+
6
6
  def simple_message
7
7
  mail
8
8
  end
@@ -17,4 +17,9 @@ class TestMailer < ActionMailer::Base
17
17
  format.html
18
18
  end
19
19
  end
20
+
21
+ def message_with_attachment
22
+ attachments['empty.gif'] = File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'empty.gif')
23
+ mail(:subject => "Message with attachment.")
24
+ end
20
25
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Delivering emails in batches' do
4
+ let(:api_client) { Postmark::ApiClient.new('POSTMARK_API_TEST') }
5
+ let(:messages) { [TestMailer.simple_message,
6
+ TestMailer.tagged_message,
7
+ TestMailer.multipart_message,
8
+ TestMailer.message_with_attachment] }
9
+
10
+ it 'delivers messages in batches' do
11
+ expect { api_client.deliver_messages(messages) }.
12
+ to change{messages.all? { |m| m.delivered?} }.to true
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Delivering messages with postmark-rails" do
4
+ let(:api_key) { 'POSTMARK_API_TEST' }
5
+
6
+ before do
7
+ ActionMailer::Base.postmark_settings = { :api_key => api_key }
8
+ end
9
+
10
+ it 'delivers a simple message' do
11
+ message = TestMailer.simple_message
12
+
13
+ expect { message.deliver }.to change{message.delivered?}.to(true)
14
+ end
15
+
16
+ it 'delivers a tagged message' do
17
+ message = TestMailer.tagged_message
18
+
19
+ expect { message.deliver }.to change{message.delivered?}.to(true)
20
+ end
21
+
22
+ it 'delivers a multipart message' do
23
+ message = TestMailer.multipart_message
24
+
25
+ expect { message.deliver }.to change{message.delivered?}.to(true)
26
+ end
27
+
28
+ it 'delivers a message with attachments' do
29
+ message = TestMailer.message_with_attachment
30
+
31
+ expect { message.deliver }.to change{message.delivered?}.to(true)
32
+ end
33
+ end
@@ -1,34 +1,44 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "PostmarkRails3" do
4
+ let!(:api_client) { Postmark::ApiClient.new('api-key') }
5
+
4
6
  it "should allow setting an api key" do
5
- Postmark.stub!(:send_through_postmark)
6
7
  ActionMailer::Base.postmark_settings = {:api_key => 'api-key'}
7
8
  ActionMailer::Base.postmark_settings[:api_key].should == 'api-key'
8
- Postmark.should_receive(:api_key=).with('api-key')
9
- TestMailer.simple_message.deliver
10
9
  end
11
-
10
+
12
11
  it "should use postmark for delivery" do
13
- Postmark.should_receive(:send_through_postmark) do |message|
12
+ Postmark::ApiClient.should_receive(:new) { api_client }
13
+ api_client.should_receive(:deliver_message) do |message|
14
14
  message.subject.should == "hello"
15
15
  end
16
16
  TestMailer.simple_message.deliver
17
17
  end
18
18
 
19
19
  it "should allow tagging of message" do
20
- Postmark.should_receive(:send_through_postmark) do |message|
20
+ Postmark::ApiClient.should_receive(:new) { api_client }
21
+ api_client.should_receive(:deliver_message) do |message|
21
22
  message.tag.to_s.should == "delivery"
22
23
  end
23
24
  TestMailer.tagged_message.deliver
24
25
  end
25
-
26
+
26
27
  it "should work with multipart messages" do
27
- Postmark.should_receive(:send_through_postmark) do |message|
28
+ Postmark::ApiClient.should_receive(:new) { api_client }
29
+ api_client.should_receive(:deliver_message) do |message|
28
30
  message.should be_multipart
29
31
  message.body_text.strip.should == "hello"
30
32
  message.body_html.strip.should == "<b>hello</b>"
31
33
  end
32
34
  TestMailer.multipart_message.deliver
33
35
  end
36
+
37
+ it 'should work with messages containing attachments' do
38
+ Postmark::ApiClient.should_receive(:new) { api_client }
39
+ api_client.should_receive(:deliver_message) do |message|
40
+ message.should have_attachments
41
+ end
42
+ TestMailer.message_with_attachment.deliver
43
+ end
34
44
  end
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
4
  require 'rubygems'
5
5
  require 'postmark'
6
6
  require 'postmark-rails'
7
+ require 'json'
7
8
 
8
9
  ActionMailer::Base.delivery_method = :postmark
9
10
  ActionMailer::Base.prepend_view_path(File.join(File.dirname(__FILE__), "fixtures", "views"))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postmark-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2010-11-22 00:00:00.000000000 Z
14
+ date: 2013-07-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: actionmailer
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ! '>='
22
22
  - !ruby/object:Gem::Version
23
- version: '0'
23
+ version: 3.0.0
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,7 +28,7 @@ dependencies:
28
28
  requirements:
29
29
  - - ! '>='
30
30
  - !ruby/object:Gem::Version
31
- version: '0'
31
+ version: 3.0.0
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: postmark
34
34
  requirement: !ruby/object:Gem::Requirement
@@ -36,7 +36,7 @@ dependencies:
36
36
  requirements:
37
37
  - - ~>
38
38
  - !ruby/object:Gem::Version
39
- version: '0.9'
39
+ version: '1.0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '0.9'
47
+ version: '1.0'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rake
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -61,22 +61,6 @@ dependencies:
61
61
  - - ! '>='
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
- - !ruby/object:Gem::Dependency
65
- name: rspec
66
- requirement: !ruby/object:Gem::Requirement
67
- none: false
68
- requirements:
69
- - - ! '>='
70
- - !ruby/object:Gem::Version
71
- version: 2.7.0
72
- type: :development
73
- prerelease: false
74
- version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
- requirements:
77
- - - ! '>='
78
- - !ruby/object:Gem::Version
79
- version: 2.7.0
80
64
  description: Use this plugin in your rails applications to send emails through the
81
65
  Postmark API
82
66
  email: ilya@wildbit.com
@@ -84,7 +68,7 @@ executables: []
84
68
  extensions: []
85
69
  extra_rdoc_files:
86
70
  - LICENSE
87
- - README.rdoc
71
+ - README.md
88
72
  files:
89
73
  - .document
90
74
  - .gitignore
@@ -92,17 +76,24 @@ files:
92
76
  - CHANGELOG.rdoc
93
77
  - Gemfile
94
78
  - LICENSE
95
- - README.rdoc
79
+ - README.md
96
80
  - Rakefile
81
+ - gemfiles/Gemfile.actionmailer-3.0.x
82
+ - gemfiles/Gemfile.actionmailer-3.2.x
83
+ - gemfiles/Gemfile.actionmailer-4.0.x
97
84
  - lib/postmark-rails.rb
98
85
  - lib/postmark-rails/version.rb
99
86
  - lib/postmark_delivery_method.rb
100
87
  - postmark-rails.gemspec
88
+ - spec/fixtures/empty.gif
101
89
  - spec/fixtures/models/test_mailer.rb
90
+ - spec/fixtures/views/test_mailer/message_with_attachment.erb
102
91
  - spec/fixtures/views/test_mailer/multipart_message.html.erb
103
92
  - spec/fixtures/views/test_mailer/multipart_message.text.erb
104
93
  - spec/fixtures/views/test_mailer/simple_message.erb
105
94
  - spec/fixtures/views/test_mailer/tagged_message.erb
95
+ - spec/integration/batch_delivery_spec.rb
96
+ - spec/integration/delivery_spec.rb
106
97
  - spec/postmark-rails_spec.rb
107
98
  - spec/spec.opts
108
99
  - spec/spec_helper.rb
@@ -110,7 +101,7 @@ homepage: http://postmarkapp.com
110
101
  licenses: []
111
102
  post_install_message: ! "\n ==================\n Thanks for installing the postmark-rails
112
103
  gem. If you don't have an account, please sign up at http://postmarkapp.com/.\n
113
- \ Review the README.rdoc for implementation details and examples.\n ==================\n
104
+ \ Review the README.md for implementation details and examples.\n ==================\n
114
105
  \ "
115
106
  rdoc_options:
116
107
  - --charset=UTF-8
@@ -124,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
115
  version: '0'
125
116
  segments:
126
117
  - 0
127
- hash: -776780947269731110
118
+ hash: 4431092584679978138
128
119
  required_rubygems_version: !ruby/object:Gem::Requirement
129
120
  none: false
130
121
  requirements:
@@ -133,19 +124,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
124
  version: '0'
134
125
  segments:
135
126
  - 0
136
- hash: -776780947269731110
127
+ hash: 4431092584679978138
137
128
  requirements: []
138
129
  rubyforge_project:
139
- rubygems_version: 1.8.24
130
+ rubygems_version: 1.8.25
140
131
  signing_key:
141
132
  specification_version: 3
142
133
  summary: Postmark adapter for ActionMailer
143
134
  test_files:
135
+ - spec/fixtures/empty.gif
144
136
  - spec/fixtures/models/test_mailer.rb
137
+ - spec/fixtures/views/test_mailer/message_with_attachment.erb
145
138
  - spec/fixtures/views/test_mailer/multipart_message.html.erb
146
139
  - spec/fixtures/views/test_mailer/multipart_message.text.erb
147
140
  - spec/fixtures/views/test_mailer/simple_message.erb
148
141
  - spec/fixtures/views/test_mailer/tagged_message.erb
142
+ - spec/integration/batch_delivery_spec.rb
143
+ - spec/integration/delivery_spec.rb
149
144
  - spec/postmark-rails_spec.rb
150
145
  - spec/spec.opts
151
146
  - spec/spec_helper.rb
data/README.rdoc DELETED
@@ -1,159 +0,0 @@
1
- = postmark-rails gem
2
-
3
- {<img src="https://travis-ci.org/wildbit/postmark-rails.png?branch=master" alt="Build Status" />}[https://travis-ci.org/wildbit/postmark-rails] {<img src="https://codeclimate.com/github/wildbit/postmark-rails.png" />}[https://codeclimate.com/github/wildbit/postmark-rails]
4
-
5
- The Postmark Rails Gem is a drop-in plug-in for ActionMailer to send emails via Postmark, an email delivery service for web apps. The gem has been created for fast implementation and fully supports all of Postmark’s features.
6
-
7
- == Supported Rails Versions
8
-
9
- * lower than 2.3: could work, but not tested
10
- * 2.3 and higher
11
- * 3.0
12
- * 4.0
13
-
14
- == Install
15
-
16
- sudo gem install postmark-rails
17
-
18
- == Requirements
19
-
20
- * "postmark" gem version 0.9 and higher is required.
21
- * You will also need a Postmark account, server and sender signature set up to use it. To get an account, sign up at http://postmarkapp.com.
22
-
23
- == Configuring your Rails application
24
-
25
- === Rails 3
26
-
27
- Add this to your Gemfile: (change version numbers if needed)
28
-
29
- gem 'postmark-rails', '0.4.2'
30
-
31
- Don't forget to run "bundle install" command every time you change something in the Gemfile.
32
-
33
- Add this to your config/application.rb:
34
-
35
- config.action_mailer.delivery_method = :postmark
36
- config.action_mailer.postmark_settings = { :api_key => "your-api-key" }
37
-
38
- === Rails 2
39
-
40
- Add this to config/environment.rb:
41
-
42
- Rails::Initializer.run do |config|
43
-
44
- ...
45
-
46
- config.gem 'postmark-rails'
47
- require 'postmark-rails'
48
-
49
- config.action_mailer.postmark_api_key = "your-api-key"
50
- config.action_mailer.delivery_method = :postmark
51
-
52
- ...
53
-
54
- end
55
-
56
- For API details, refer to the developer documentation at http://developer.postmarkapp.com.
57
-
58
- == Tagging your deliveries
59
-
60
- You can use a tag to categorize outgoing messages and attach application-specific information. Tagging the different types of email that you send lets you review statistics and bounce reports separately. Read more at http://developer.postmarkapp.com/developer-build.html#message-format.
61
-
62
- === Rails 3
63
-
64
- class TestMailer < ActionMailer::Base
65
-
66
- def tagged_message
67
- mail(
68
- :subject => 'hello',
69
- :to => 'sheldon@bigbangtheory.com',
70
- :from => 'leonard@bigbangtheory.com',
71
- :tag => 'my-tag'
72
- )
73
- end
74
-
75
- end
76
-
77
- === Rails 2
78
-
79
- class SuperMailer < ActionMailer::Base
80
-
81
- def email
82
- from "no-reply@example.com"
83
- subject "Some marvelous email message"
84
- recipients "someone-fancy@example.com"
85
- tag "my-another-tag"
86
- end
87
-
88
- end
89
-
90
- == Sending attachments
91
-
92
- You can also send file attachments with Postmark. Read our Developer docs for additional information: http://developer.postmarkapp.com/developer-build.html#attachments.
93
-
94
- The Postmark gem is compatible with [ActionMailer attachments API](http://api.rubyonrails.org/classes/ActionMailer/Base.html#method-i-attachments).
95
-
96
- The legacy #postmark_attachments method is no longer supported on Rails 3.2.13 and above.
97
-
98
- === Rails 3
99
-
100
- class TestMailer < ActionMailer::Base
101
-
102
- def message_with_attachment
103
- attachment['42.jpg'] = File.read("/path/to/file")
104
- mail(
105
- :subject => 'hello',
106
- :to => 'sheldon@bigbangtheory.com',
107
- :from => 'leonard@bigbangtheory.com'
108
- )
109
- end
110
-
111
- end
112
-
113
- === Rails 2
114
-
115
- class SuperMailer < ActionMailer::Base
116
-
117
- def email
118
- from "no-reply@example.com"
119
- subject "Some marvelous email message"
120
- recipients "someone-fancy@example.com"
121
- postmark_attachments [File.open("/path/to/file")]
122
- end
123
-
124
- end
125
-
126
- You can pass either an array of File objects or a single object. Postmark will detect the file name automatically and send an attachment with the "application/octet-stream" content type. If you want more control on how attachments get formatted, you can pass Hash objects, which contain the custom settings such as file name or content-type. Here is an example:
127
-
128
- #
129
- # Don't forget to read your file and base64-encode it,
130
- # before assigning it to "Content".
131
- #
132
- message.postmark_attachments = {
133
- "Name" => "fancy-file-name.jpg",
134
- "Content" => [ IO.read("path/to/file") ].pack("m"),
135
- "ContentType" => "image/jpeg"
136
- }
137
-
138
- == Note on Patches/Pull Requests
139
-
140
- * Fork the project.
141
- * Make your feature addition or bug fix.
142
- * Add tests for it. This is important so we don’t break it in a future version unintentionally.
143
- * Commit, do not mess with rakefile, version, or history.
144
- * Send a pull request. Bonus points for topic branches.
145
-
146
- == Authors & Contributors
147
-
148
- * Artem Chistyakov
149
- * Petyo Ivanov
150
- * Ilya Sabanin
151
- * Hristo Deshev
152
- * Randy Schmidt
153
- * Chris Williams
154
- * Nicolás Sanguinetti
155
- * Laust Rud Jacobsen (rud)
156
-
157
- == Copyright
158
-
159
- Copyright © 2010 Wildbit LLC. See LICENSE for details.