feat: update Resend email delivery method to use headers for sender and recipient
This commit is contained in:
parent
a119641c21
commit
217cecae9e
@ -6,9 +6,9 @@ module Mail # rubocop:disable Style/ClassAndModuleChildren
|
|||||||
|
|
||||||
def deliver!(mail)
|
def deliver!(mail)
|
||||||
Resend::Emails.send(
|
Resend::Emails.send(
|
||||||
from: mail.smtp_envelope_from,
|
from: mail.header[:from].to_s,
|
||||||
to: mail.smtp_envelope_to,
|
to: mail.header[:to].to_s,
|
||||||
subject: mail.subject,
|
subject: mail.header[:subject].to_s,
|
||||||
html: mail.decoded,
|
html: mail.decoded,
|
||||||
text: sanitize_html(mail.decoded)
|
text: sanitize_html(mail.decoded)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -3,11 +3,14 @@ require 'rails_helper'
|
|||||||
describe Mail::ResendProvider do
|
describe Mail::ResendProvider do
|
||||||
let(:provider) { described_class.new({}) }
|
let(:provider) { described_class.new({}) }
|
||||||
let(:mail) do
|
let(:mail) do
|
||||||
instance_double(Mail::Message,
|
Mail::Message.new(
|
||||||
smtp_envelope_from: 'sender@example.com',
|
headers: {
|
||||||
smtp_envelope_to: ['receiver@example.com'],
|
from: 'Sender <sender@example.com>',
|
||||||
subject: 'Test Email',
|
to: ['Receiver <receiver@example.com>'],
|
||||||
decoded: '<p>This is a test email message.</p>')
|
subject: 'Test Email'
|
||||||
|
},
|
||||||
|
body: '<p>This is a test email message.</p>'
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#deliver!' do
|
describe '#deliver!' do
|
||||||
@ -15,8 +18,8 @@ describe Mail::ResendProvider do
|
|||||||
response = instance_double(HTTParty::Response, success?: true)
|
response = instance_double(HTTParty::Response, success?: true)
|
||||||
allow(Resend::Emails).to receive(:send)
|
allow(Resend::Emails).to receive(:send)
|
||||||
.with(
|
.with(
|
||||||
from: 'sender@example.com',
|
from: 'Sender <sender@example.com>',
|
||||||
to: ['receiver@example.com'],
|
to: 'Receiver <receiver@example.com>',
|
||||||
subject: 'Test Email',
|
subject: 'Test Email',
|
||||||
html: '<p>This is a test email message.</p>',
|
html: '<p>This is a test email message.</p>',
|
||||||
text: 'This is a test email message.'
|
text: 'This is a test email message.'
|
||||||
@ -32,8 +35,8 @@ describe Mail::ResendProvider do
|
|||||||
it 'raises a DeliveryError with the error message' do
|
it 'raises a DeliveryError with the error message' do
|
||||||
allow(Resend::Emails).to receive(:send)
|
allow(Resend::Emails).to receive(:send)
|
||||||
.with(
|
.with(
|
||||||
from: 'sender@example.com',
|
from: 'Sender <sender@example.com>',
|
||||||
to: ['receiver@example.com'],
|
to: 'Receiver <receiver@example.com>',
|
||||||
subject: 'Test Email',
|
subject: 'Test Email',
|
||||||
html: '<p>This is a test email message.</p>',
|
html: '<p>This is a test email message.</p>',
|
||||||
text: 'This is a test email message.'
|
text: 'This is a test email message.'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user