Skip to content

Allow to disable sending of emails by an event without showing an error/flash message #1232

@tntrpsw

Description

@tntrpsw

Using the event "SendMailServicePrepareAndSendEvent" it is possible to change the mail object and also to prevent the sending of an email (receiver and/or sender).
This works without any problem, but in the frontend an error is shown (flash message), informing the website customer that an email could not be sent in addition (!) to the normal "thank you" message ("settings.flexform.thx.body").

We are considering to use this event in order to disable the sending of emails on a case-by-case basis using the isAllowedToSend() call with "false" as a parameter.

I would suggest to change the prepareAndSend() function, so that it returns true instead of false, if the if-condition "isAllowedToSend" is false.
That should suppress the flash/error message, if the mail was not sent, because explicitly disabling the sending of emails should not be treated as an error.

TYPO3 12.4.26 (legacy, not composer)
powermail 12.5.1
PHP 8.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions