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.

Comments

nno created an issue. See original summary.

nno’s picture

Issue summary: View changes
nno’s picture

Issue summary: View changes
bojanz’s picture

Status: Active » Needs review

There's a patch here, updating status.

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()

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.

bojanz’s picture

Title: Add reply-to address to MailHandler » Allow mails sent via MailHandler to specify a reply-to address
Status: Needs review » Needs work

Retitling. 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.

bojanz’s picture

Status: Needs work » Needs review
StatusFileSize
new3.24 KB

Here's an updated patch.

  • bojanz committed 7ecb2f6 on 8.x-2.x authored by nno
    Issue #3094175 by nno, bojanz: Allow mails sent via MailHandler to...
bojanz’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.