No mail send to bcc for commerce order receipt mail

Created on 1 December 2021, over 2 years ago
Updated 29 November 2023, 7 months ago

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.

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇳🇱Netherlands PROMES

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇲🇩Moldova Utilvideo Chisinau

    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

  • Status changed to Postponed: needs info about 1 year ago
  • 🇬🇧United Kingdom AdamPS

    These needs clear steps to reproduce.

  • 🇲🇩Moldova Utilvideo Chisinau

    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.
    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--
    
  • 🇬🇧United Kingdom AdamPS

    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.

  • 🇨🇦Canada hcksharp

    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.

  • 🇲🇩Moldova Utilvideo Chisinau

    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.

  • 🇬🇧United Kingdom AdamPS

    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.

  • 🇨🇦Canada hcksharp

    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.

  • 🇬🇧United Kingdom AdamPS

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

  • 🇲🇩Moldova Utilvideo Chisinau

    #28 Commerce file send bcc order Receipt is here
    web/modules/contrib/commerce/modules/order/src/Mail/OrderReceiptMail.php
    Part of code. I also replace bcc with email for testing. See that bcc exists but in emails not contains.

        $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);
    
  • 🇬🇧United Kingdom AdamPS

    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.

  • 🇲🇩Moldova Utilvideo Chisinau

    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.

  • 🇬🇧United Kingdom AdamPS

    Thanks @Utilvideo.

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

  • Status changed to Closed: outdated 8 months ago
  • 🇬🇧United Kingdom AdamPS

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

  • 🇬🇧United Kingdom Londova

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

  • 🇦🇹Austria pauleb

    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?

Production build 0.69.0 2024