Skip to content

Commit 6f0493d

Browse files
committed
Get ReplyTo Working
1 parent 416c5a8 commit 6f0493d

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/Mailer/Transport/SendGridTransport.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@ protected function _prepareEmailAddresses(Message $message)
189189
$this->_reqParams['from'] = (object)['email' => key($from)];
190190
}
191191

192+
$replyTo = $message->getReplyTo();
193+
if (!empty($replyTo)) {
194+
if (key($replyTo) != $replyTo[key($replyTo)]) {
195+
$this->_reqParams['reply_to'] = (object)['email' => key($replyTo), 'name' => $replyTo[key($replyTo)]];
196+
197+
} else {
198+
$this->_reqParams['reply_to'] = (object)['email' => key($replyTo)];
199+
}
200+
}
201+
192202
$emails = [];
193203
foreach ($message->getTo() as $toEmail => $toName) {
194204
$emails['to'][] = [
@@ -273,9 +283,7 @@ protected function _sendEmail()
273283
],
274284
];
275285

276-
277-
$response = $this->Client
278-
->post("{$this->getConfig('apiEndpoint')}/mail/send", json_encode($this->_reqParams), $options);
286+
$response = $this->Client->post("{$this->getConfig('apiEndpoint')}/mail/send", json_encode($this->_reqParams), $options);
279287

280288
$result = [];
281289
$result['apiResponse'] = $response->getJson();

0 commit comments

Comments
 (0)