Closed (fixed)
Project:
Mailer Plus (DSM+)
Version:
1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
18 May 2022 at 13:12 UTC
Updated:
26 Jul 2022 at 15:59 UTC
Jump to comment: Most recent
Comments
Comment #2
gilbertdelyon commentedComment #3
adamps commentedIt's not broken for everyone, so we need more info to debug. Please add more info especially about the list of addresses - you can substitute one character for another for confidentiality.
That's entirely separate from this issue - please can you remove it here and create a new one if you really wish.
Comment #4
gilbertdelyon commentedComment #5
gilbertdelyon commentedIll do my best, but for the moment I removed Symfony Mailer from my site in favour of the "good old" Swift Mailer, and it works without any change in the code of my custom module.
You are right. Its removed.
Comment #6
gilbertdelyon commented@AdamPS,
When a new node of a certain type is published my custom module is sending 2 emails:
- mail 1: notification to users
- mail 2: notification to site admin (with lighter content)
In costum module the PHP sequence is as follows:
Email to users:
Email to site admin:
In SwiftMailer:
Mail to users: It works!
Mail to site admin: it works !
So far so good!
In SymfonyMailer:
Mail to users: Mail not sent. Error sending email: Email "" does not comply with addr-spec of RFC 2822.
Mail to site admi: it works !
I also tested other separators ',' (without space) and ';'. Same result.
Uninstall Symfony Mailer. Reinstall Swift Mailer. It works again !
PHP 8.0.19
Drupal 9.3.13
Symfony Mailer Alpha 9
Please ask for additionnal test if you need, (but not before next monday)
Comment #7
adamps commentedOK so it an error with an address of "" - an empty address. So perhaps the problem is with the 'To' address which you say "remains empty".
Please can you share more of your code? In particular, the call to
->mail()what do you pass for$to?Comment #8
gilbertdelyon commentedhere it is:
And again: It works in SwiftMailer
Comment #9
gilbertdelyon commented@AdamPS,
I could perform some more tests:
First test:
it works!
so, you are right. No issue with Bcc, but issue with empty "$to"
and this is not the result I want !
Second test:
Doesn't work. Error sending email: Email "" does not comply with addr-spec of RFC 2822.
Third test:
It works, but
//to="";should sent to nobody, instead it sends to 'sitemailadress@sitedomain'So, the question is: With Symfony Mailer what is the value for
$to=??if I want the mail to be sent only to "Bcc" ??Comment #10
gilbertdelyon commentedComment #11
gilbertdelyon commentedComment #12
adamps commentedI guess that the problem is with empty "To" and not related to the multiple "Bcc".
The documentation for
MailManagerInterfaceandMailInterfacedo not mention that $to can be an empty string. You have tested it successfully with Swift Mailer however it might fail with other mailer implementations such as PhpMail.Comment #13
lamp5After latest updates I have also problems with all of my custom mails. Example:
$to is filled but I can see the same error message.
Comment #14
adamps commented@lamp5 If your $to is filled in then maybe it's not the same issue? Please can you post the actual value? You can swap some characters for confidentiality. We need a clear example that is a valid email yet causes an error so other people can reproduce.
Comment #15
lamp5Ok I found where is the problem right now:
I set $reply to FALSE, it should be NULL or email address.
Comment #16
ippy commentedI wanted to say a quick thanks to @lamp5 for posting c15 as it provided an invaluable clue.
[NB This is not about empty "to" - apologies if it feels like a hijack, but I'm not sure where else to note it]
I spent a long time picking apart a similar scenario with some inherited code during a D9 upgrade (BC and coming from Swift, creating and queuing messages for batch processing), wondering why an apparently valid "to" value was returning "does not comply with addr-spec of RFC 2822."
In this case it turned out that \Drupal::service('plugin.manager.mail') was missing a $reply value entirely. I added a default reply address and, mmm, unsurprisingly perhaps, mail is created and sent as expected.
Comment #17
adamps commentedThanks for the updates in #15/#16. It's a shame that the error message (which comes from the library code) does not indicate which header is causing the problem. Possibly we could try to catch the error and throw a clearer one, but it would be better to raise an issue upstream.
This email remains open for empty To address. I feel it's unclear whether that is allowed or not. However I would accept a patch which presumably would only be adding one if.
Comment #19
adel-by commentedIn my case it was content_moderation_notifications module that sometimes sends an empty "To" to the MailManagerReplacement service.
I added a simple check to replace the empty string with null, and the email was sent as expected.
I don't know if this belongs here or content_moderation_notifications but here is the patch.
Comment #21
adamps commentedComment #23
adamps commentedGreat thanks