- Issue created by @hansfn
- π¬π§United Kingdom adamps
You are right.
I suggest the fix is something like this:
if (!$send) { $email->addProcessor(function () { throw new SkipMailException('Sending disabled'); }, PHASE_POST_RENDER, 1000); }
- π³π΄Norway hansfn
Thx for the quick reply. I'll test and come back to you later this week - if confirmation is needed ;-)
- π³π΄Norway hansfn
I have been playing a little bit with
$email->addProcessor
, but I don't seem to be able to add / call it at a valid phase - should be init (0) and I'm only able to do it the build phase (1) it seems. Could you give me some more pointers? - Assigned to adamps
- π¬π§United Kingdom adamps
Yes I see what you mean. I don't have an immediate answer, I'll think about itπ
- Status changed to Closed: won't fix
over 1 year ago 12:32pm 9 November 2023 - π³π΄Norway hansfn
Thx for you time and effort. It seems the way forward is to avoid using MailManager (for Symfony Mailer) and rather implement support for Symfony Mailer using the new API.
- Status changed to Active
over 1 year ago 12:16pm 21 November 2023 - π¬π§United Kingdom adamps
I'm sorry I wish I'd been more positive. It's quite challenging maintaining this module with so many people having different requests, and sometimes I get stressed.
MailManagerReplacement is not perfect and I never intended or expected it to be perfect, but still it's being used successfully on 1000s of sites. In fact it's an extremely important part of this module, and no way can we remove it.
I found a challenge in the dialogue here that seemed to be insisting and expecting a level of perfection that in fact I never promised. As I said before, I'm willing to fix it if it's easy. If not then we have other options.
- Status changed to Fixed
11 days ago 8:19am 28 May 2025 - π¬π§United Kingdom adamps
In the original MailManager, the behaviour of $send is arbitrary. I agree it calls format(), but not send(), however there isn't any clear definition of what belongs in each. If we look at the obsolete swiftmailer for example, the send phase is adding headers, attachments, embedding images etc. I don't see how our replacement can replicate this exactly as it will be different for each plug-in.
With this module there are two possibilities:
- Any plug-in can halt processing by throwing a SkipMailException at a precisely defined point - with any weight during any phase.
- Any plug-in can set a NULL transport, and the mail is processed to the end but not sent.
In 2.x, we now have ReplacementEmailProcessor. If $send is false, then it throws SkipMailException in the post-render phase with weight 1000. I feel this is a pretty good solution for "format but not send" - arguably better than what swiftmailer didπ.