Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add $connection to MAIL_PROCESS_BEFORE event #1414

Merged
merged 3 commits into from Jul 7, 2022

Conversation

glensc
Copy link
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.

None yet

1 participant