Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 82c1fe0

Browse files
authored
Merge pull request #5 from joelharkes/respects_reply_to_header
Fix respects reply to header
2 parents 4419e97 + be40833 commit 82c1fe0

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/InboundEmail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function reply(Mailable $mailable)
161161
}
162162
}
163163

164-
return Mail::to($this->from())->send($mailable);
164+
return Mail::to($this->headerValue('Reply-To') ?: $this->from())->send($mailable);
165165
}
166166

167167
public function forward($recipients)

tests/InboundEmailTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,26 @@ public function it_can_reply_to_mails()
155155

156156
Mail::to('[email protected]')->send(new TestMail);
157157

158-
Mail::assertSent(ReplyMail::class);
158+
Mail::assertSent(ReplyMail::class, function (ReplyMail $mail){
159+
return $mail->hasTo('[email protected]');
160+
});
161+
}
162+
163+
164+
/** @test */
165+
public function it_respects_to_reply_to_header()
166+
{
167+
Mailbox::from('[email protected]', function (InboundEmail $email) {
168+
Mail::fake();
169+
170+
$email->reply(new ReplyMail);
171+
});
172+
173+
Mail::to('[email protected]')->send((new TestMail)->replyTo('[email protected]'));
174+
175+
Mail::assertSent(ReplyMail::class, function (ReplyMail $mail){
176+
return $mail->hasTo('[email protected]') && ! $mail->hasTo('[email protected]');
177+
});
159178
}
160179

161180
/** @test */

0 commit comments

Comments
 (0)