Closed (outdated)
Project:
Mailer Plus (DSM+)
Version:
1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 Dec 2021 at 11:44 UTC
Updated:
29 Nov 2023 at 08:58 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
promesI 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)
Comment #3
axle_foley00 commentedI decided to give Symfony Mailer a try on my Drupal Commerce development site and I got the same error as you @PROMES:
Anyone with any ideas why that is?
Comment #4
promesMaybe the new symfony_mailer 1.0.0-alpha4 will solve this. Not yet tested.
Comment #5
axle_foley00 commented@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.
Comment #6
jsacksick commentedThe notice reported in #2 is fixed separately, as part of #3250480: Undefined index to in onMailSend().
Comment #7
jsacksick commentedSo, 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).
Comment #8
adamps commentedSince #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?
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 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??
Comment #9
promesI 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.
Comment #10
adamps commentedThanks 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:"
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?
Comment #11
promes@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.
Comment #12
adamps commentedThanks 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.
Comment #13
promes@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.
Comment #14
adamps commentedThis 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.
Comment #15
promes@AdamPS. The $email->getParam('bcc') contains the correct bcc addres in CommerceEmailBuilder.
Comment #16
adamps commentedOK, 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😃.
Comment #17
socialnicheguru commentedComment #18
david.qdoscc commentedCC and BCC emails are not sent from webform email handlers either. Using Symfony Mailer and Symfony Mailer BC.
Comment #19
adamps commentedThis 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.
Comment #20
pavelculacov commentedSome 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
Comment #21
pavelculacov commentedComment #22
adamps commentedThese needs clear steps to reproduce.
Comment #23
pavelculacov commentedReproduse:
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
Comment #24
adamps commentedIt 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.
Comment #25
hcksharp commentedI 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.
Comment #26
pavelculacov commentedAll 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.
Comment #27
adamps commentedThanks 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.
Comment #28
hcksharp commentedAdamPS 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.
Comment #29
adamps commented@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.
Comment #30
pavelculacov commented#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.
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
Comment #31
adamps commentedThanks @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.Comment #32
pavelculacov commentedHere template mail body, bcc is missed.
attach dd for your debug.
Comment #33
adamps commentedThanks @Utilvideo.
The header is there, so Drupal Symfony Mailer is working correctly. The problem is in Symfony Mailer Library or MailHog.
Comment #34
adamps commentedIt looks like all the bugs in this area have been fixed now
Comment #35
londova commentedThe 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...
Comment #36
pauleb commentedI 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?