mail_plugger 1.0.0.rc1 → 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 +4 -4
- data/CHANGELOG.md +54 -2
- data/README.md +40 -22
- data/lib/fake_plugger/delivery_method.rb +164 -0
- data/lib/fake_plugger/railtie.rb +14 -0
- data/lib/mail_plugger.rb +11 -2
- data/lib/mail_plugger/delivery_method.rb +2 -2
- data/lib/mail_plugger/version.rb +1 -1
- metadata +17 -48
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -22
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -16
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.rubocop.yml +0 -53
- data/.travis.yml +0 -22
- data/Appraisals +0 -13
- data/CODE_OF_CONDUCT.md +0 -14
- data/CONTRIBUTING.md +0 -26
- data/Gemfile +0 -19
- data/Gemfile.lock +0 -92
- data/Rakefile +0 -11
- data/bin/console +0 -17
- data/bin/setup +0 -8
- data/docs/usage_in_ruby_on_rails.md +0 -182
- data/docs/usage_in_script_or_console.md +0 -158
- data/docs/usage_of_attachments_in_ruby_on_rails.md +0 -110
- data/docs/usage_of_aws_ses_in_ruby_on_rails.md +0 -136
- data/docs/usage_of_delivery_method.md +0 -104
- data/docs/usage_of_mailgun_in_ruby_on_rails.md +0 -58
- data/docs/usage_of_mandrill_in_ruby_on_rails.md +0 -104
- data/docs/usage_of_more_delivery_system_in_ruby_on_rails.md +0 -332
- data/docs/usage_of_one_delivery_system_with_more_send_methods_in_ruby_on_rails.md +0 -119
- data/docs/usage_of_plug_in_method.md +0 -62
- data/docs/usage_of_postmark_in_ruby_on_rails.md +0 -59
- data/docs/usage_of_secial_options_in_ruby_on_rails.md +0 -90
- data/docs/usage_of_sendgrid_in_ruby_on_rails.md +0 -82
- data/docs/usage_of_sparkpost_in_ruby_on_rails.md +0 -142
- data/gemfiles/.bundle/config +0 -2
- data/gemfiles/mail_2.6.gemfile +0 -15
- data/gemfiles/mail_2.6.gemfile.lock +0 -95
- data/gemfiles/mail_2.7.0.gemfile +0 -15
- data/gemfiles/mail_2.7.0.gemfile.lock +0 -93
- data/gemfiles/mail_2.7.gemfile +0 -15
- data/gemfiles/mail_2.7.gemfile.lock +0 -93
- data/images/mail_plugger.png +0 -0
- data/mail_plugger.gemspec +0 -40
@@ -1,22 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Bug report
|
3
|
-
about: Create a report to help us improve
|
4
|
-
---
|
5
|
-
|
6
|
-
**Describe the bug**
|
7
|
-
A clear and concise description of what the bug is.
|
8
|
-
|
9
|
-
**To Reproduce**
|
10
|
-
This is important! Providing us with a reliable way to reproduce a problem will expedite its solution.
|
11
|
-
|
12
|
-
**Expected behavior**
|
13
|
-
A clear and concise description of what you expected to happen.
|
14
|
-
|
15
|
-
**Actual behavior
|
16
|
-
Describe here what actually happened.
|
17
|
-
|
18
|
-
**Screenshots**
|
19
|
-
If applicable, add screenshots to help explain your problem.
|
20
|
-
|
21
|
-
**Additional context**
|
22
|
-
Add any other context about the problem here.
|
@@ -1,16 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: Feature request
|
3
|
-
about: Suggest an idea for this project
|
4
|
-
---
|
5
|
-
|
6
|
-
**Is your feature request related to a problem? Please describe.**
|
7
|
-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
8
|
-
|
9
|
-
**Describe the solution you'd like**
|
10
|
-
A clear and concise description of what you want to happen.
|
11
|
-
|
12
|
-
**Describe alternatives you've considered**
|
13
|
-
A clear and concise description of any alternative solutions or features you've considered.
|
14
|
-
|
15
|
-
**Additional context**
|
16
|
-
Add any other context or screenshots about the feature request here.
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require:
|
2
|
-
- rubocop-performance
|
3
|
-
- rubocop-rspec
|
4
|
-
|
5
|
-
AllCops:
|
6
|
-
NewCops: enable
|
7
|
-
SuggestExtensions: false
|
8
|
-
Exclude:
|
9
|
-
- 'gemfiles/**/*'
|
10
|
-
|
11
|
-
Layout/LineLength:
|
12
|
-
Max: 80
|
13
|
-
|
14
|
-
Metrics/BlockLength:
|
15
|
-
Exclude:
|
16
|
-
- spec/**/*
|
17
|
-
|
18
|
-
Metrics/CyclomaticComplexity:
|
19
|
-
Max: 15
|
20
|
-
|
21
|
-
Metrics/MethodLength:
|
22
|
-
Max: 20
|
23
|
-
|
24
|
-
Metrics/ModuleLength:
|
25
|
-
Max: 150
|
26
|
-
|
27
|
-
Lint/AmbiguousBlockAssociation:
|
28
|
-
Exclude:
|
29
|
-
- spec/**/*
|
30
|
-
|
31
|
-
Style/Documentation:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
Style/DocumentationMethod:
|
35
|
-
Enabled: true
|
36
|
-
|
37
|
-
RSpec/ContextWording:
|
38
|
-
Enabled: false
|
39
|
-
|
40
|
-
RSpec/MessageChain:
|
41
|
-
Enabled: false
|
42
|
-
|
43
|
-
RSpec/MessageSpies:
|
44
|
-
EnforcedStyle: receive
|
45
|
-
|
46
|
-
RSpec/MultipleExpectations:
|
47
|
-
Enabled: false
|
48
|
-
|
49
|
-
RSpec/MultipleMemoizedHelpers:
|
50
|
-
Max: 10
|
51
|
-
|
52
|
-
RSpec/NestedGroups:
|
53
|
-
Enabled: false
|
data/.travis.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
---
|
2
|
-
env:
|
3
|
-
global:
|
4
|
-
- CC_TEST_REPORTER_ID=b510dcaf1de6f05f2fcdd623d5870628f3ab45124249a0819a63bea1257e8e79
|
5
|
-
language: ruby
|
6
|
-
cache: bundler
|
7
|
-
rvm:
|
8
|
-
- 2.5
|
9
|
-
- 2.6
|
10
|
-
- 2.7
|
11
|
-
- 3.0
|
12
|
-
before_install: gem install bundler -v 2.2.3
|
13
|
-
before_script:
|
14
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
15
|
-
- chmod +x ./cc-test-reporter
|
16
|
-
- ./cc-test-reporter before-build
|
17
|
-
gemfile:
|
18
|
-
- gemfiles/mail_2.7.gemfile
|
19
|
-
- gemfiles/mail_2.7.0.gemfile
|
20
|
-
- gemfiles/mail_2.6.gemfile
|
21
|
-
after_script:
|
22
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/Appraisals
DELETED
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# The MailPlugger Community Code of Conduct
|
2
|
-
|
3
|
-
**Note:** We have picked the following code of conduct based on [Ruby's own code of conduct](https://www.ruby-lang.org/en/conduct/).
|
4
|
-
|
5
|
-
This document provides a few simple community guidelines for a safe, respectful,
|
6
|
-
productive, and collaborative place for any person who is willing to contribute
|
7
|
-
to the MailPlugger community. It applies to all "collaborative spaces", which are
|
8
|
-
defined as community communications channels (such as mailing lists, submitted
|
9
|
-
patches, commit comments, etc.).
|
10
|
-
|
11
|
-
* Participants will be tolerant of opposing views.
|
12
|
-
* Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
|
13
|
-
* When interpreting the words and actions of others, participants should always assume good intentions.
|
14
|
-
* Behaviour which can be reasonably considered harassment will not be tolerated.
|
data/CONTRIBUTING.md
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# Contributing
|
2
|
-
|
3
|
-
If you discover issues, have ideas for improvements or new features,
|
4
|
-
please report them to the [issue tracker](https://github.com/norbertszivos/mail_plugger/issues) of the repository or
|
5
|
-
submit a pull request. Please, try to follow these guidelines when you
|
6
|
-
do so.
|
7
|
-
|
8
|
-
## Issue reporting
|
9
|
-
|
10
|
-
* Check that the issue has not already been reported.
|
11
|
-
* Check that the issue has not already been fixed in the latest code.
|
12
|
-
* Be clear, concise and precise in your description of the problem.
|
13
|
-
* Open an issue with a descriptive title and summary.
|
14
|
-
* Include any relevant code to the issue summary.
|
15
|
-
|
16
|
-
## Pull requests
|
17
|
-
|
18
|
-
* Fork the project.
|
19
|
-
* Use a feature branch to easily amend a pull request later, if necessary.
|
20
|
-
* Write good commit messages.
|
21
|
-
* Use the same coding conventions as the rest of the project.
|
22
|
-
* If your change has a corresponding open GitHub issue, prefix the commit message with `[#github-issue-number]`.
|
23
|
-
* Make sure to add tests for it.
|
24
|
-
* Make sure the test suite is passing (usually this is as simple as running `bundle exec rake`).
|
25
|
-
* Squash related commits together.
|
26
|
-
* Open a pull request that relates to *only* one subject with a clear title and description.
|
data/Gemfile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in mail_plugger.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem 'appraisal'
|
9
|
-
|
10
|
-
gem 'rake', '~> 13.0'
|
11
|
-
|
12
|
-
# Ruby static code analyzer and code formatter, code linter in short
|
13
|
-
gem 'rubocop', '~> 1.7', require: false
|
14
|
-
gem 'rubocop-performance', require: false
|
15
|
-
gem 'rubocop-rspec', require: false
|
16
|
-
|
17
|
-
gem 'rspec', '~> 3.0'
|
18
|
-
gem 'simplecov', require: false
|
19
|
-
gem 'webmock', '~> 3.0'
|
data/Gemfile.lock
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
mail_plugger (1.0.0.rc1)
|
5
|
-
mail (~> 2.5)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
addressable (2.7.0)
|
11
|
-
public_suffix (>= 2.0.2, < 5.0)
|
12
|
-
appraisal (2.3.0)
|
13
|
-
bundler
|
14
|
-
rake
|
15
|
-
thor (>= 0.14.0)
|
16
|
-
ast (2.4.1)
|
17
|
-
crack (0.4.5)
|
18
|
-
rexml
|
19
|
-
diff-lcs (1.4.4)
|
20
|
-
docile (1.3.4)
|
21
|
-
hashdiff (1.0.1)
|
22
|
-
mail (2.7.1)
|
23
|
-
mini_mime (>= 0.1.1)
|
24
|
-
mini_mime (1.0.2)
|
25
|
-
parallel (1.20.1)
|
26
|
-
parser (3.0.0.0)
|
27
|
-
ast (~> 2.4.1)
|
28
|
-
public_suffix (4.0.6)
|
29
|
-
rainbow (3.0.0)
|
30
|
-
rake (13.0.3)
|
31
|
-
regexp_parser (2.0.3)
|
32
|
-
rexml (3.2.4)
|
33
|
-
rspec (3.10.0)
|
34
|
-
rspec-core (~> 3.10.0)
|
35
|
-
rspec-expectations (~> 3.10.0)
|
36
|
-
rspec-mocks (~> 3.10.0)
|
37
|
-
rspec-core (3.10.1)
|
38
|
-
rspec-support (~> 3.10.0)
|
39
|
-
rspec-expectations (3.10.1)
|
40
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.10.0)
|
42
|
-
rspec-mocks (3.10.1)
|
43
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
-
rspec-support (~> 3.10.0)
|
45
|
-
rspec-support (3.10.1)
|
46
|
-
rubocop (1.8.0)
|
47
|
-
parallel (~> 1.10)
|
48
|
-
parser (>= 3.0.0.0)
|
49
|
-
rainbow (>= 2.2.2, < 4.0)
|
50
|
-
regexp_parser (>= 1.8, < 3.0)
|
51
|
-
rexml
|
52
|
-
rubocop-ast (>= 1.2.0, < 2.0)
|
53
|
-
ruby-progressbar (~> 1.7)
|
54
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
55
|
-
rubocop-ast (1.4.0)
|
56
|
-
parser (>= 2.7.1.5)
|
57
|
-
rubocop-performance (1.9.2)
|
58
|
-
rubocop (>= 0.90.0, < 2.0)
|
59
|
-
rubocop-ast (>= 0.4.0)
|
60
|
-
rubocop-rspec (2.1.0)
|
61
|
-
rubocop (~> 1.0)
|
62
|
-
rubocop-ast (>= 1.1.0)
|
63
|
-
ruby-progressbar (1.11.0)
|
64
|
-
simplecov (0.21.2)
|
65
|
-
docile (~> 1.1)
|
66
|
-
simplecov-html (~> 0.11)
|
67
|
-
simplecov_json_formatter (~> 0.1)
|
68
|
-
simplecov-html (0.12.3)
|
69
|
-
simplecov_json_formatter (0.1.2)
|
70
|
-
thor (1.0.1)
|
71
|
-
unicode-display_width (2.0.0)
|
72
|
-
webmock (3.11.0)
|
73
|
-
addressable (>= 2.3.6)
|
74
|
-
crack (>= 0.3.2)
|
75
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
76
|
-
|
77
|
-
PLATFORMS
|
78
|
-
ruby
|
79
|
-
|
80
|
-
DEPENDENCIES
|
81
|
-
appraisal
|
82
|
-
mail_plugger!
|
83
|
-
rake (~> 13.0)
|
84
|
-
rspec (~> 3.0)
|
85
|
-
rubocop (~> 1.7)
|
86
|
-
rubocop-performance
|
87
|
-
rubocop-rspec
|
88
|
-
simplecov
|
89
|
-
webmock (~> 3.0)
|
90
|
-
|
91
|
-
BUNDLED WITH
|
92
|
-
2.2.4
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# frozen_string_literal: true
|
4
|
-
|
5
|
-
require 'bundler/setup'
|
6
|
-
require 'mail_plugger'
|
7
|
-
require 'mail'
|
8
|
-
|
9
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
10
|
-
# with your gem easier. You can also use a different console, if you like.
|
11
|
-
|
12
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
13
|
-
# require "pry"
|
14
|
-
# Pry.start
|
15
|
-
|
16
|
-
require 'irb'
|
17
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
@@ -1,182 +0,0 @@
|
|
1
|
-
# How to use MailPlugger in Ruby on Rails
|
2
|
-
|
3
|
-
After to add `mail_plugger` gem and the gem of API of the mail provider, create `config/initializers/mail_plugger.rb` file and add something similar.
|
4
|
-
|
5
|
-
```ruby
|
6
|
-
# NOTE: This is just an example for testing...
|
7
|
-
class TestApiClientClass
|
8
|
-
def initialize(options = {})
|
9
|
-
@settings = { api_key: '12345' }
|
10
|
-
@options = options
|
11
|
-
end
|
12
|
-
|
13
|
-
def deliver
|
14
|
-
# e.g. API.new(@settings).client.post(generate_mail_hash)
|
15
|
-
puts " >>> settings: #{@settings.inspect}"
|
16
|
-
puts " >>> options: #{@options.inspect}"
|
17
|
-
puts " >>> generate_mail_hash: #{generate_mail_hash.inspect}"
|
18
|
-
{ response: 'OK' }
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def generate_mail_hash
|
24
|
-
{
|
25
|
-
to: generate_recipients,
|
26
|
-
from: {
|
27
|
-
email: @options[:from].first
|
28
|
-
},
|
29
|
-
subject: @options[:subject],
|
30
|
-
content: [
|
31
|
-
{
|
32
|
-
type: 'text/plain',
|
33
|
-
value: @options[:text_part]
|
34
|
-
},
|
35
|
-
{
|
36
|
-
type: 'text/html; charset=UTF-8',
|
37
|
-
value: @options[:html_part]
|
38
|
-
}
|
39
|
-
]
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def generate_recipients
|
44
|
-
@options[:to].map do |to|
|
45
|
-
{
|
46
|
-
email: to
|
47
|
-
}
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
MailPlugger.plug_in('test_api_client') do |api|
|
53
|
-
api.delivery_options = %i[from to subject text_part html_part]
|
54
|
-
api.client = TestApiClientClass
|
55
|
-
end
|
56
|
-
```
|
57
|
-
|
58
|
-
Then change `config/application.rb` file.
|
59
|
-
|
60
|
-
```ruby
|
61
|
-
config.action_mailer.delivery_method = :mail_plugger
|
62
|
-
```
|
63
|
-
|
64
|
-
So now we should add a mailer method. Let's create `app/mailers/test_mailer.rb` file.
|
65
|
-
|
66
|
-
```ruby
|
67
|
-
class TestMailer < ApplicationMailer
|
68
|
-
default from: 'from@example.com'
|
69
|
-
|
70
|
-
def send_test
|
71
|
-
mail subject: 'Test email', to: 'to@example.com'
|
72
|
-
end
|
73
|
-
end
|
74
|
-
```
|
75
|
-
|
76
|
-
Then we should add views (the body) of this email, so create `app/views/test_mailer/send_test.html.erb`
|
77
|
-
|
78
|
-
```erb
|
79
|
-
<p>Test email body</p>
|
80
|
-
```
|
81
|
-
|
82
|
-
and `app/views/test_mailer/send_test.text.erb`.
|
83
|
-
|
84
|
-
```erb
|
85
|
-
Test email body
|
86
|
-
```
|
87
|
-
|
88
|
-
In the `rails console` we can try it out.
|
89
|
-
|
90
|
-
```ruby
|
91
|
-
TestMailer.send_test.deliver_now
|
92
|
-
# Rendering test_mailer/send_test.html.erb within layouts/mailer
|
93
|
-
# Rendered test_mailer/send_test.html.erb within layouts/mailer (1.3ms)
|
94
|
-
# Rendering test_mailer/send_test.text.erb within layouts/mailer
|
95
|
-
# Rendered test_mailer/send_test.text.erb within layouts/mailer (0.5ms)
|
96
|
-
#TestMailer#send_test: processed outbound mail in 62.2ms
|
97
|
-
# >>> settings: {:api_key=>"12345"}
|
98
|
-
# >>> options: {"from"=>["from@example.com"], "to"=>["to@example.com"], "subject"=>"Test email", "text_part"=>"Test email body\n\n", "html_part"=>"<!DOCTYPE html>\n<html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <style>\n /* Email styles need to be inline */\n </style>\n </head>\n\n <body>\n <p>Test email body</p>\n\n </body>\n</html>\n"}
|
99
|
-
# >>> generate_mail_hash: {:to=>[{:email=>"to@example.com"}], :from=>{:email=>"from@example.com"}, :subject=>"Test email", :content=>[{:type=>"text/plain", :value=>"Test email body\n\n"}, {:type=>"text/html; charset=UTF-8", :value=>"<!DOCTYPE html>\n<html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <style>\n /* Email styles need to be inline */\n </style>\n </head>\n\n <body>\n <p>Test email body</p>\n\n </body>\n</html>\n"}]}
|
100
|
-
#Sent mail to to@example.com (12.2ms)
|
101
|
-
#Date: Sat, 02 Jan 2021 15:08:53 +0100
|
102
|
-
#From: from@example.com
|
103
|
-
#To: to@example.com
|
104
|
-
#Message-ID: <5ff07e7597b40_104cfebb4988d3@100S-Mac.local.mail>
|
105
|
-
#Subject: Test email
|
106
|
-
#Mime-Version: 1.0
|
107
|
-
#Content-Type: multipart/alternative;
|
108
|
-
# boundary="--==_mimepart_5ff07e75956a7_104cfebb498739";
|
109
|
-
# charset=UTF-8
|
110
|
-
#Content-Transfer-Encoding: 7bit
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#----==_mimepart_5ff07e75956a7_104cfebb498739
|
114
|
-
#Content-Type: text/plain;
|
115
|
-
# charset=UTF-8
|
116
|
-
#Content-Transfer-Encoding: 7bit
|
117
|
-
#
|
118
|
-
#Test email body
|
119
|
-
#
|
120
|
-
#
|
121
|
-
#----==_mimepart_5ff07e75956a7_104cfebb498739
|
122
|
-
#Content-Type: text/html;
|
123
|
-
# charset=UTF-8
|
124
|
-
#Content-Transfer-Encoding: 7bit
|
125
|
-
#
|
126
|
-
#<!DOCTYPE html>
|
127
|
-
#<html>
|
128
|
-
# <head>
|
129
|
-
# <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
130
|
-
# <style>
|
131
|
-
# /* Email styles need to be inline */
|
132
|
-
# </style>
|
133
|
-
# </head>
|
134
|
-
#
|
135
|
-
# <body>
|
136
|
-
# <p>Test email body</p>
|
137
|
-
#
|
138
|
-
# </body>
|
139
|
-
#</html>
|
140
|
-
#
|
141
|
-
#----==_mimepart_5ff07e75956a7_104cfebb498739--
|
142
|
-
|
143
|
-
#=> #<Mail::Message:61100, Multipart: true, Headers: <Date: Sat, 02 Jan 2021 15:08:53 +0100>, <From: from@example.com>, <To: to@example.com>, <Message-ID: <5ff07e7597b40_104cfebb4988d3@100S-Mac.local.mail>>, <Subject: Test email>, <Mime-Version: 1.0>, <Content-Type: multipart/alternative; boundary="--==_mimepart_5ff07e75956a7_104cfebb498739"; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>>
|
144
|
-
|
145
|
-
# or use ! to not render mail
|
146
|
-
|
147
|
-
TestMailer.send_test.deliver_now!
|
148
|
-
# Rendering test_mailer/send_test.html.erb within layouts/mailer
|
149
|
-
# Rendered test_mailer/send_test.html.erb within layouts/mailer (0.1ms)
|
150
|
-
# Rendering test_mailer/send_test.text.erb within layouts/mailer
|
151
|
-
# Rendered test_mailer/send_test.text.erb within layouts/mailer (0.0ms)
|
152
|
-
#TestMailer#send_test: processed outbound mail in 20.9ms
|
153
|
-
# >>> settings: {:api_key=>"12345"}
|
154
|
-
# >>> options: {"from"=>["from@example.com"], "to"=>["to@example.com"], "subject"=>"Test email", "text_part"=>"Test email body\n\n", "html_part"=>"<!DOCTYPE html>\n<html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <style>\n /* Email styles need to be inline */\n </style>\n </head>\n\n <body>\n <p>Test email body</p>\n\n </body>\n</html>\n"}
|
155
|
-
# >>> generate_mail_hash: {:to=>[{:email=>"to@example.com"}], :from=>{:email=>"from@example.com"}, :subject=>"Test email", :content=>[{:type=>"text/plain", :value=>"Test email body\n\n"}, {:type=>"text/html; charset=UTF-8", :value=>"<!DOCTYPE html>\n<html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <style>\n /* Email styles need to be inline */\n </style>\n </head>\n\n <body>\n <p>Test email body</p>\n\n </body>\n</html>\n"}]}
|
156
|
-
#=> #<Mail::Message:61140, Multipart: true, Headers: <From: from@example.com>, <To: to@example.com>, <Subject: Test email>, <Mime-Version: 1.0>, <Content-Type: multipart/alternative; boundary="--==_mimepart_5ff082bd7aab5_10afcebb4503a4"; charset=UTF-8>>
|
157
|
-
```
|
158
|
-
|
159
|
-
Let's add delivery settings as well in `config/initializers/mail_plugger.rb`.
|
160
|
-
|
161
|
-
```ruby
|
162
|
-
MailPlugger.plug_in('test_api_client') do |api|
|
163
|
-
api.delivery_options = %i[from to subject text_part html_part]
|
164
|
-
api.delivery_settings = { return_response: true }
|
165
|
-
api.client = TestApiClientClass
|
166
|
-
end
|
167
|
-
```
|
168
|
-
|
169
|
-
Then in the `rails console`.
|
170
|
-
|
171
|
-
```ruby
|
172
|
-
TestMailer.send_test.deliver_now!
|
173
|
-
# Rendering test_mailer/send_test.html.erb within layouts/mailer
|
174
|
-
# Rendered test_mailer/send_test.html.erb within layouts/mailer (0.8ms)
|
175
|
-
# Rendering test_mailer/send_test.text.erb within layouts/mailer
|
176
|
-
# Rendered test_mailer/send_test.text.erb within layouts/mailer (0.4ms)
|
177
|
-
#TestMailer#send_test: processed outbound mail in 37.0ms
|
178
|
-
# >>> settings: {:api_key=>"12345"}
|
179
|
-
# >>> options: {"from"=>["from@example.com"], "to"=>["to@example.com"], "subject"=>"Test email", "text_part"=>"Test email body\n\n", "html_part"=>"<!DOCTYPE html>\n<html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <style>\n /* Email styles need to be inline */\n </style>\n </head>\n\n <body>\n <p>Test email body</p>\n\n </body>\n</html>\n"}
|
180
|
-
# >>> generate_mail_hash: {:to=>[{:email=>"to@example.com"}], :from=>{:email=>"from@example.com"}, :subject=>"Test email", :content=>[{:type=>"text/plain", :value=>"Test email body\n\n"}, {:type=>"text/html; charset=UTF-8", :value=>"<!DOCTYPE html>\n<html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <style>\n /* Email styles need to be inline */\n </style>\n </head>\n\n <body>\n <p>Test email body</p>\n\n </body>\n</html>\n"}]}
|
181
|
-
#=> {:response=>"OK"}
|
182
|
-
```
|