When using mailHandler to send email adding Reply-To in $params['headers'] doesn't work. It seams that we have to set reply-to parameter in mailManager.
Not sure if this is right approach but it works for my use case when sending email from EventSubscriberInterface with:
$params = [
'id' => 'order_receipt',
'from' => $from,
'order' => $order,
'reply-to' => $order->getStore()->getEmail(),
];As a side note, I think that it could be safer to send order receipt emails from \Drupal::config('system.site')->get('mail') with reply-to $order->getStore()->getEmail() or even better to have From address and Reply-To address in Store settings.
The problem with current setup is that order receipt will fail when using Office365 as SMTP server and probably some other providers that require same From address and account username.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3094175-6-mailhandler-reply-to.patch | 3.24 KB | bojanz |
| mailhandler-reply-to.patch | 1016 bytes | nno |
Comments
Comment #2
nno commentedComment #3
nno commentedComment #4
bojanz commentedThere's a patch here, updating status.
I've looked into this, and it doesn't feel like a safe assumption to make, because having different domains in From and Reply-to can be problematic.
Comment #5
bojanz commentedRetitling. Let's fix the API limitation here, and leave the additional UI configurability for another issue.
We need to expand MailHandlerTest to confirm that the reply-to address is getting used.
Comment #6
bojanz commentedHere's an updated patch.
Comment #8
bojanz commentedCommitted, thanks!