Score:0

Sievie for outgoing mail - dovecot

jp flag

I need to make a filter for outgoing mail. To copy messages if "to" contains the given e-mail address.I have:

# rule:[Copy to slack]
if address :contains "to" "[email protected]"
{
    redirect :copy "[email protected]";
}

and i try

# rule:[Copy to slack]
if address :contains "to" "[email protected]"
{
    redirect :copy "[email protected]";
}

or

# rule:[Copy to ]
if address :contains "to" "[email protected]"
{
      fileinto "INBOX.Redmine";
}

But every time the filter doesn't work.

This only works if I'm sending from the address I have in "to" or other local mail.

Any ideas?

anx avatar
fr flag
anx
Sieve is integrated into Dovecot to be triggered during *final delivery* of mail, or by actions via IMAP - not for submission. Please [edit] your question to clarify the context in which your script is meant to be executed. Typically, submitted mail would not involve Dovecot except for a copy being optionally stored in the Sent folder.
onev avatar
jp flag
In this case "to" is external email, example gmail.com
onev avatar
jp flag
For local mailboxes - works properly.
in flag
it works properly for local mailboxes because it's an incoming mail for Dovecot. Dovecot does not send mails, your MTA does.
Score:1
fr flag
anx

It does not work because it cannot work this way: If you are sending mail, you are sending it to port 465 directly to Postfix - no Sieve script will be executed.

If you want to use the sieve language to work on outgoing mail, you would have to put in much more effort, because it is not nicely integrated into common software, at least nowhere near as nice as the Pigeonhole Sieve integration in Dovecot which will only trigger in two specific use cases:

  1. on receiving mail, a.k.a the final delivery stage of mail destined for a mailbox Dovecot manages, or
  2. on managing a mailbox, specifically actions of a local or IMAP-connected client on a mailbox Dovecot manages.

Notable, that integration will not handle the case of mail submission: While Dovecot does include a submission proxy, it is generally not involved at all in that direction, and in rare cases where this is used, then still not handling Sieve.

You got a few options now:

  • trigger your script on the mail that is stored to a "sent" mailbox (but that would not act on mail that is not stored in that mailbox)
  • replace your script with built-in functionality of Postfix. recipient_bcc_maps comes to mind
  • configure postfix header_checks to simply reject mail that does not follow your policy (e.g. skips over the desired To: header, then reject all incomplete versions of it)
  • configure the copy in some milter/filter
  • configure an (preferably new, local) address which you setup to be expanded to the two addresses you want to receive the mail, let users send their mail there
  • pipe mail for that recipient to a script, possibly one using your Sieve script (unlikely your best shot: using sieve outside of the LDA use case is simply not well supported by any existing software)
onev avatar
jp flag
i try recipient_bcc_maps (the exim equivalent) but this only works for sender addresses (I need specific recipients) (and not forward just a copy). ```copy_from_skrzynka: driver = redirect condition = ${if eq{$sender_address}{[email protected]}{yes}{no}} data = [email protected] unseen``` But I don't see a global function for the recipient. I'm thinking about the script. Only how can I send copies from the .Sent directory to the chosen e-mail address
anx avatar
fr flag
anx
Odd that you mention *Exim*, but your question is tagged *Postfix*. What is the MTA that you submit to?
onev avatar
jp flag
Sorry, I gave the wrong tag. Exim.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.