Skip to content

Feature: Add $connection to MAIL_PROCESS_BEFORE event#1414

Merged
glensc merged 3 commits intoeventum:masterfrom
glensc:blockIncomingMail-delete
Jul 7, 2022
Merged

Feature: Add $connection to MAIL_PROCESS_BEFORE event#1414
glensc merged 3 commits intoeventum:masterfrom
glensc:blockIncomingMail-delete

Conversation

@glensc
Copy link
Copy Markdown
Member

@glensc glensc commented Jul 7, 2022

This allows to have workflow event to delete email:

    /**
     * Ignore emails from being processed
     */
    public function blockIncomingMail(GenericEvent $event): void
    {
        /** @var ImapMessage $mail */
        $mail = $event->getSubject();

        if (!in_array($mail->getSender(), self::BLOCK_SENDERS, true)) {
            return;
        }

        $event->stopPropagation();
        $this->debug('Stopped mail from {}', ['sender' => $mail->getSender()]);
        $dumper = new MailDumper(self::DUMP_PATH);
        $dumper->dump($mail);

        /** @var ImapConnection $connection */
        $connection = $event['connection'];
        $connection->deleteMessage($mail);
    }

@glensc glensc added this to the 3.10.11 milestone Jul 7, 2022
@glensc glensc changed the title Feature: Add $connection to SystemEvents::MAIL_PROCESS_BEFORE event Feature: Add $connection to MAIL_PROCESS_BEFORE event Jul 7, 2022
@glensc glensc merged commit e3cd6fa into eventum:master Jul 7, 2022
@glensc glensc deleted the blockIncomingMail-delete branch July 7, 2022 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant