Skip to content

Commit 47ffeda

Browse files
authored
Merge pull request #36 from railsware/iy/reply_to
Add `reply_to`
2 parents cecd916 + 6e62a70 commit 47ffeda

File tree

11 files changed

+28
-3
lines changed

11 files changed

+28
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [2.2.0] - 2024-12-18
2+
3+
- Added `reply_to` parameter support
4+
15
## [2.1.2] - 2024-12-13
26

37
- Improved handling of invalid `from`, `to`, `cc`, `bcc` headers when sending

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
mailtrap (2.1.2)
4+
mailtrap (2.2.0)
55

66
GEM
77
remote: https://rubygems.org/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ mail = Mailtrap::Mail::Base.new(
5252
to: [
5353
{ email: 'your@email.com' }
5454
],
55+
reply_to: { email: 'support@example.com', name: 'Mailtrap Reply-To' },
5556
subject: 'You are awesome!',
5657
text: "Congrats for sending test email with Mailtrap!"
5758
)

examples/action_mailer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# To add `category` and `custom_variables`, add them to the mail generation:
1919
mail(
2020
to: 'your@email.com',
21+
reply_to: 'Mailtrap Reply-To <support@example.com>',
2122
subject: 'You are awesome!',
2223
category: 'Test category',
2324
custom_variables: { test_variable: 'abc' }

examples/email_template.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
to: [
77
{ email: 'your@email.com' }
88
],
9+
reply_to: { email: 'support@example.com', name: 'Mailtrap Reply-To' },
910
template_uuid: '2f45b0aa-bbed-432f-95e4-e145e1965ba2',
1011
template_variables: {
1112
'user_name' => 'John Doe'

examples/full.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
to: [
77
{ email: 'your@email.com', name: 'Your name' }
88
],
9+
reply_to: { email: 'support@example.com', name: 'Mailtrap Reply-To' },
910
cc: [
1011
{ email: 'cc@email.com', name: 'Copy To' }
1112
],

lib/mailtrap/mail/base.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
module Mailtrap
66
module Mail
77
class Base
8-
attr_accessor :from, :to, :cc, :bcc, :headers, :custom_variables, :subject, :text, :html, :category
8+
attr_accessor :from, :to, :reply_to, :cc, :bcc, :headers, :custom_variables, :subject, :text, :html, :category
99
attr_reader :attachments
1010

1111
def initialize( # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
1212
from: nil,
1313
to: [],
14+
reply_to: nil,
1415
cc: [],
1516
bcc: [],
1617
subject: nil,
@@ -23,6 +24,7 @@ def initialize( # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
2324
)
2425
@from = from
2526
@to = to
27+
@reply_to = reply_to
2628
@cc = cc
2729
@bcc = bcc
2830
@subject = subject
@@ -38,6 +40,7 @@ def as_json # rubocop:disable Metrics/MethodLength
3840
{
3941
'from' => from,
4042
'to' => to,
43+
'reply_to' => reply_to,
4144
'cc' => cc,
4245
'bcc' => bcc,
4346
'subject' => subject,

lib/mailtrap/mail/from_template.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class FromTemplate < Base
88
def initialize( # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
99
from: nil,
1010
to: [],
11+
reply_to: nil,
1112
cc: [],
1213
bcc: [],
1314
attachments: [],
@@ -19,6 +20,7 @@ def initialize( # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
1920
super(
2021
from: from,
2122
to: to,
23+
reply_to: reply_to,
2224
cc: cc,
2325
bcc: bcc,
2426
attachments: attachments,

lib/mailtrap/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Mailtrap
4-
VERSION = '2.1.2'
4+
VERSION = '2.2.0'
55
end

spec/mailtrap/mail/base_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
described_class.new(
99
from: from,
1010
to: to,
11+
reply_to: reply_to,
1112
cc: cc,
1213
bcc: bcc,
1314
subject: mail_subject,
@@ -22,6 +23,7 @@
2223

2324
let(:from) { nil }
2425
let(:to) { [] }
26+
let(:reply_to) { nil }
2527
let(:cc) { [] }
2628
let(:bcc) { [] }
2729
let(:mail_subject) { nil }
@@ -80,6 +82,7 @@
8082
end
8183

8284
context 'when all values set' do
85+
let(:reply_to) { { email: 'reply-to@railsware.com' } }
8386
let(:cc) { [{ email: 'cc@example.com' }] }
8487
let(:bcc) { [{ email: 'bcc@example.com' }] }
8588
let(:html) { '<div>Test HTML</div>' }
@@ -91,6 +94,7 @@
9194
{
9295
'from' => { email: 'test@example.com', name: 'Mailtrap User' },
9396
'to' => [{ email: 'to@example.com' }, { email: 'to2@example.com', name: 'To Two' }],
97+
'reply_to' => { email: 'reply-to@railsware.com' },
9498
'cc' => [{ email: 'cc@example.com' }],
9599
'bcc' => [{ email: 'bcc@example.com' }],
96100
'subject' => 'This is subject',
@@ -114,6 +118,7 @@
114118

115119
let(:from) { { email: 'test@example.com', name: 'Mailtrap User' } }
116120
let(:to) { [{ email: 'to@example.com' }, { email: 'to2@example.com', name: 'To Two' }] }
121+
let(:reply_to) { { email: 'reply-to@railsware.com', name: 'Reply To' } }
117122
let(:mail_subject) { 'This is subject' }
118123
let(:text) { 'This is text' }
119124
let(:cc) { [{ email: 'cc@example.com' }] }
@@ -126,6 +131,7 @@
126131
'{' \
127132
'"from":{"email":"test@example.com","name":"Mailtrap User"},' \
128133
'"to":[{"email":"to@example.com"},{"email":"to2@example.com","name":"To Two"}],' \
134+
'"reply_to":{"email":"reply-to@railsware.com","name":"Reply To"},' \
129135
'"cc":[{"email":"cc@example.com"}],' \
130136
'"bcc":[{"email":"bcc@example.com"}],' \
131137
'"subject":"This is subject",' \

0 commit comments

Comments
 (0)