Describe your bug or feature request.

I changed the bcc param in send function in OrderReceiptMail.php with an admin mailaddress. Then I did create an order and confirmed this. I did reveive a confirmation mail to my account mailaddress, but not at the bcc address.

CommentFileSizeAuthor
#32 Screenshot_2.png20.29 KBpavelculacov
#23 Screenshot_1.png11.33 KBpavelculacov

Comments

PROMES created an issue. See original summary.

promes’s picture

I found this notice in my log:
Notice: Undefined index: to in Drupal\commerce_log\EventSubscriber\OrderMailEventSubscriber->onMailSend() (line 81 of /xxx/drupal/web/modules/contrib/commerce/modules/log/src/EventSubscriber/OrderMailEventSubscriber.php)

axle_foley00’s picture

I decided to give Symfony Mailer a try on my Drupal Commerce development site and I got the same error as you @PROMES:

Notice: Undefined index: to in Drupal\commerce_log\EventSubscriber\OrderMailEventSubscriber->onMailSend() (line 82 of /var/www/drupal/web/modules/contrib/commerce/modules/log/src/EventSubscriber/OrderMailEventSubscriber.php)

Anyone with any ideas why that is?

promes’s picture

Maybe the new symfony_mailer 1.0.0-alpha4 will solve this. Not yet tested.

axle_foley00’s picture

@PROMES: That's actually the version I am currently using when I got the Notice. So unless I didn't configure something properly the notice still exists in 1.0.0-alpha4.

jsacksick’s picture

The notice reported in #2 is fixed separately, as part of #3250480: Undefined index to in onMailSend().

jsacksick’s picture

Project: Commerce Core » Mailer Plus (DSM+)
Version: 3.0.x-dev » 1.0.0-alpha3
Component: Order » Code

So, I've tested this myself, I dug into the Symfony mailer code.

And the Symfony mailer BC module doesn't currently "care" about the BCC.

So this should be fixed there. I can see that the module doesn't support multiple "to" addresses as well (See #3254085: Sending mails to multiple email addresses does not work via BC).

adamps’s picture

Since #3248894: Copy of receipt Drupal Commerce email breaks with Symfony Mailer, CommerceEmailBuilder contains code for bcc, so I expect bcc would work for the commerce order receipt. Please can someone check?

And the Symfony mailer BC module doesn't currently "care" about the BCC.

I think this is true only in "legacy mode", when there is no EmailBuilder and the BC module is trying to 'guess'. See "Compatibility" on the project page for an explanation.

I can see that the module doesn't support multiple "to" addresses as well

I think this is true in "legacy mode" or "proxy mode". Multiple to addresses would work with a native implementation.

I'm hesitant to try to fix either of these cases as they require attempting to "unrender" the address header back into a structure. The format is complex (you can't just split on comma) and the standards are changing. Code like that existed in swiftmailer and was a pain to maintain. So this isn't not necessarily a bug, it might be instead a known limitation. Multiple to addresses is perhaps a fairly rare case??

promes’s picture

I just checked with a hardcoded mailaddress in the bcc param in the send function of commerce OrderReceiptMail.php. The bcc address still did not reveice an email.

adamps’s picture

Version: 1.0.0-alpha3 » 1.x-dev
Status: Active » Postponed (maintainer needs more info)

Thanks for the update. I just tested again and it works fine for me. I edited the order type in the UI and added an address to the form field "Send a copy of the receipt to this email:"

I changed the bcc param in send function in OrderReceiptMail.php with an admin mailaddress.

This sentence is from the issue summary, but I don't understand it. Are you doing it a different way from me? Are you using the latest module version, alpha4?

promes’s picture

@AdamPS. Sorry, I was not clear. To be sure the bcc is set somewhere, I hardcoded it in the source of OrderReceiptMail.php. And then I forced sending an email. The hardcoded bcc will be removed when I receive mails on both the to and bcc address.

adamps’s picture

Thanks for the update.

Please can you try to reproduce in a more natural/standard way, using the GUI as on a real site? You can configure the BCC on the order type as I described, then place an order through the cart. This way works for me and it would be useful to know if it also works for you.

It would also be useful if you can get ksm/debugger from CommerceEmailBuilder to see the value of $email->getParam('bcc').

Unfortunately seeing as it works for me I can't really do much unless you can provide some more information about why it isn't working for you.

promes’s picture

@AdamPS
I installed the original OrderReceiptMail.php (see: xxx/modules/contrib/commerce/modules/order/src/Mail/OrderReceiptMail.php). I created an order and finished this. Still no mail on the bcc address. I did a dpr() on the bcc in OrderReceiptMail.php. The displayed value is the mailaddress as set in: admin/commerce/config/order-types/default/edit.
I did a grep on CommerceEmailBuilder and on email->getParam('bcc') in the module contrib sources of commerce. But both not found.
I haven't installed Commerce Invoice, but only send a confirmation mail, which doesn't send the bcc.

adamps’s picture

I did a grep on CommerceEmailBuilder and on email->getParam('bcc') in the module contrib sources of commerce. But both not found.

This one is part of symfony_mailer module. That's the code that should be filling in the BCC, and a good place for you to start looking.

promes’s picture

@AdamPS. The $email->getParam('bcc') contains the correct bcc addres in CommerceEmailBuilder.

adamps’s picture

OK, so you need to follow through and see where it gets lost. For example check Mailer.php around line 196. Then you can keep checking places earlier in that same function. I think you see the idea and don't need me to tell you every step😃.

socialnicheguru’s picture

david.qdoscc’s picture

CC and BCC emails are not sent from webform email handlers either. Using Symfony Mailer and Symfony Mailer BC.

adamps’s picture

Title: no mail send to bcc using symfony_mailer » No mail send to bcc for commerce order receipt mail
Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

CC and BCC emails are not sent from webform email handlers either. Using Symfony Mailer and Symfony Mailer BC.

This is as expected for webform. It would be solved by either #3262946: Add support for more headers on legacy emails or #3260134: Add EmailBuilder for Webform.

The issue reported a problem for commerce OrderReceiptMail. I tested it myself and it worked fine. I feel this issue is causing confusion and after 2 months there is still no info on how to reproduce so let's close it.

pavelculacov’s picture

Some problem, with Symfony Mailer Test make added custom bcc. in own MailHog not see two mail, only single.
But in mail structure not exists bcc information

pavelculacov’s picture

Status: Closed (cannot reproduce) » Active
adamps’s picture

Status: Active » Postponed (maintainer needs more info)

These needs clear steps to reproduce.

pavelculacov’s picture

StatusFileSize
new11.33 KB

Reproduse:
1) Install/Enable Drupal Symfony Mailer
2) Go to https://drupalcommerce.ddev.site/admin/config/system/mailer/test
3) Add Bcc element for "Test email"
4) Send email for test.

In my MailHog dont have two email only one (Also testen on Hosting with real emails.).
If review the structure of mail bcc not persist.

Bcc email, see in attach file.

Mail Body

Content-Type: multipart/alternative; boundary=76xs_vsk
Date: Tue, 25 Apr 2023 07:34:10 +0000
From: Drush Site-Install <admin@example.com>
MIME-Version: 1.0
Message-ID: <cf478a414d6e51fec59fa1b1f50c0f4d@example.com>
Received: from [127.0.0.1] by mailhog.example (MailHog)
          id HE0uk4_cFIFGMiPQfH8vUouDOK2hYuG5znKVVb09AwU=@mailhog.example; Tue, 25 Apr 2023 07:34:10 +0000
Return-Path: <admin@example.com>
Sender: Drush Site-Install <admin@example.com>
Subject: Test email from Drush Site-Install
To: some@example.com
X-Mailer: Drupal

--76xs_vsk
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

This is a test email from Drush Site-Install
[https://drupalcommerce.ddev=
.site/].

--76xs_vsk
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable


<html>
<body>
<div class=3D"email-type-symfony-mailer email-sub-type=
-test">
  <table width=3D"100%" cellpadding=3D"0" cellspacing=3D"0">
  =
  <tr>
      <td>
        <div style=3D"padding: 0px 0px 0px 0px;" clas=
s=3D"clearfix">
         =20
<p>This is a test email from <a href=3D"http=
s://drupalcommerce.ddev.site/">Drush Site-Install</a>.</p>

        </d=
iv>
      </td>
    </tr>
  </table>
</div>
</body>
</html>

--76xs_vsk--
adamps’s picture

It works fine for me. I guess it's a problem with your transport - please try with SMTP. NB the warning on this page https://symfony.com/doc/current/mailer.html#using-built-in-transports.

hcksharp’s picture

I am experiencing the same issue as OP on 1.x-dev and 1.2.1. I am using Drupal Symfony Mailer on 3 sites with email commerce receipts being send to client, however no bcc are sent (specified at admin/commerce/config/order-types). I am also using webform and get bcc/cc send no issue on contact form and other forms on those sites. Transport settings are SMPT.

To further investigate I spun up a basic site on ddev 9.5.8 Drupal (PHP 8.1.16) with only commerce2 default settings and Admin Toolbar. Commerce receipt is send fine. No bcc/cc are send. Using Mailhog as local client.

I switched transport settings from SMPT to Sendmail setting default via edit link, with no change in the above. No errors are logged.

Any advise would be appreciated to get this working. Seams overkill to use the commerce email to get a bcc for an incoming order.

pavelculacov’s picture

All started from commerce 2 Bcc OrderConfirm. Also tested in WebForm BCC added. Not working all without SMTP.
With smtp not tested. But always worked with swiftmailer but after migrated to symfony_mailer. Bcc not receiving and not exits in Mail Template at all.

adamps’s picture

Thanks to you both for the updates. It all helps get more information, but unfortunately still I can't reproduce.

Please can you try to set a BCC using "Mailer Policy"? Type = Commerce, Sub-type = order_receipt.

hcksharp’s picture

Issue tags: +Commerce Core

AdamPS thanks for the quick response. Did try your suggestions, but no luck. Ended up taking a step back and uninstalling Drupal Symfony Mailer all together. So it turns out that with a basic 9.5.8 Drupal and Commerce Core 8.x-2.35 no bcc are sent (as specified at admin/commerce/config/order-types).

Order emails are coming though fine, just no styles for the orders with this approach. Also on the default contact form the "Send yourself a copy" works.

I am thinking that the "not working bcc" is more likely a Commerce Core bug, unless something is wonky or I missing something with my composer install of the above on a ddev environment.

Thanks for all the work you do. Cheers.

adamps’s picture

@hcksharp Thanks for the update.

In my own testing at first I made a mistake: I set the TO and the BCC to different aliases of the same mailbox and I got only one email. When I set them to different mailboxes then I got two emails.

pavelculacov’s picture

#28 Commerce file send bcc order Receipt is here
web/modules/contrib/commerce/modules/order/src/Mail/OrderReceiptMail.php
Part of code, bcc exists. I also replace bcc variable with email string for testing, On Mailhog Source on open email headers, dont see mail bcc that is set.

    $params = [
      'id' => 'order_receipt',
      'from' => $order->getStore()->getEmailFromHeader(),
      'bcc' => $bcc,
      'order' => $order,
      'resend' => $resend,
    ];
    $customer = $order->getCustomer();
    if ($customer->isAuthenticated()) {
      $params['langcode'] = $customer->getPreferredLangcode();
    }

    return $this->mailHandler->sendMail($to, $subject, $body, $params);

About ddev environment. just install commerce core, enable commerce order and checkout. On on order type edit, enable checkbox
"Send a copy of the receipt to this email:"
https://drupalcommerce.ddev.site/admin/commerce/config/order-types/defau...
That enough to test.

"Order emails are coming though fine, just no styles for the orders with this approach. Also on the default contact form the "Send yourself a copy" works."

Here is not send BCC, send are copy of email.

#29
@AdamPS also testing on different emails. Not working at all

adamps’s picture

Thanks @Utilvideo.

I did exactly the same as #30 and it works for me.

In Mailer.php line 265 there is a ksm() statement, in a comment. Can you enable devel, uncomment the line (remove the // ) and then check the result? The headers should contain the bcc.

pavelculacov’s picture

StatusFileSize
new20.29 KB

Here template mail body, bcc is missed.

Content-Type: multipart/alternative; boundary=YZTJEKJq
Date: Tue, 02 May 2023 06:21:13 +0000
From: Drush Site-Install <admin@example.com>
MIME-Version: 1.0
Message-ID: <d4246f9dc7d9339154377432d35d8dc6@example.com>
Received: from [127.0.0.1] by mailhog.example (MailHog)
          id VQu6rJ6QM4ebI2y3ul4d99d4bkBA8obcTUw0pOvXzCw=@mailhog.example; Tue, 02 May 2023 06:21:13 +0000
Return-Path: <admin@example.com>
Sender: Drush Site-Install <admin@example.com>
Subject: Order #6 confirmed
To: admin@example.com
X-Mailer: Drupal

--YZTJEKJq
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

attach dd for your debug.

adamps’s picture

Thanks @Utilvideo.

The header is there, so Drupal Symfony Mailer is working correctly. The problem is in Symfony Mailer Library or MailHog.

adamps’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

It looks like all the bugs in this area have been fixed now

londova’s picture

The problem still exists.
The copy of commerce order is NOT being sent to the email indicated in "Send a copy of the receipt to this email", that was setup in
/admin/commerce/config/order-types/default...

pauleb’s picture

I second Londova.
On my site the problem also still exists.
The customer gets the confirmation mail, but no copy is sent the configured email address.

Is there a relevant other issue to follow or to find a workaround?