Is it possible to filter messages received via a sync job?

Currently, I’m relying on a third-party account to forward messages to a mailcow account and using sieve in SOGo to move it to a specific folder, this works well but not all messages are being forwarded from the third-party.

I’m looking into pulling mail from mailcow via Sync Jobs but sieve filters don’t seem to be applied to mail received this way, I’ve tried pre-filter which stops a sync job from pulling mail and a post filter which fetches mail but doesn’t seem to do any filtering.

My attempt at a filter is as follows:

require ["fileinto", "editheader", "variables"];

if address "To" "pneu*****@*****media.com" {
	if header :matches "Subject" "*" {
		set "subject" "$(1)";
	}

	deleteheader "Subject:";
	addheader :last "Subject" "[VM] $(subject)";
	fileinto "INBOX/Pneu*****";
}

The idea is to change the subject so third-party messages can be identified and move it to a different folder.

Any help would be appreciated.

10 months later
  • [deleted]

Did you find a solution here?
How do the mails run through the filter during the sync job?

    Have something to say?

    Join the community by quickly registering to participate in this discussion. We'd like to see you joining our great moo-community!

    [deleted] Hi,

    No, I never found a resolution to pulling the mail with mailcow and filtering, so I’m relying on the source to push mail to mailcow and having a filter sort the mail, which works well enough.

    The problem I was getting is that any spam messages which arrived at the source account were being forwarded along with the good mail but rspamd was rejecting the forwarded spam and sending an error message back to the source account, after enough failed attempts to deliver the spam message the source account gave up on forwarding to mailcow.

    Turning on spam filtering at the source seems to work fairly well, and most of the spam isn’t forwarded and occasional failures to deliver messages doesn’t seem to upset the source account. I would prefer to have everything handled by mailcow, but that doesn’t seem possible.

    No one is typing