recipient delimiter and sieve filters

André Rodier andre at rodier.me
Sat Mar 24 10:16:14 EET 2018


Dear all,

I have found a way to  automatically copy sent emails in the "Sent"
folder, but I am not sure it is the simplest and more reliable way on
the long term.

I am open to suggestions if I miss a feature in Dovecot - or Postfix,
that allows me to do this. I vaguely remember an SMTP extension that do
that, but my memory could be wrong.

First, I use "~" as a recipient delimiter. Then, I set up a postfix
senders_bcc_map that add the ~Sent part:

andre at homebox.space → bcc: andre~Sent at homebox.space

It worked, except that the emails was marked as new.

I tried first to add a global sieve filter like this:
----------------------------------------------------------------------
# Sieve script executed before for user
require ["fileinto","imap4flags"];

# Move automatically copied emails to the sent folder
# And mark them as read
if header :contains "Delivered-To" "~Sent"
{
  setflag "\\Seen";
  fileinto "Sent";
}
----------------------------------------------------------------------
But it did not work, so maybe there is a trick I am not aware of.


If I use the "Received" header and a regex, it works
----------------------------------------------------------------------
require ["fileinto","imap4flags","regex"];
if header :regex "Received" "for <[a-z]+~Sent at homebox.space>;"
{
  setflag "\\Seen";
  fileinto "Sent";
}
----------------------------------------------------------------------

This is working perfectly, but there is limitations, IMHO.

- If the recipient delimiter is not compatible with a regex (e.g. "+"),
then the script will probably fail.

- Parsing every new email using a regular expression might not be the
best option in term of system load.

So, I finally use this:
----------------------------------------------------------------------
# Move automatically copied emails to the sent folder
# And mark them as read
require ["fileinto","imap4flags"];
if header :contains "Received" "~Sent"
{
  setflag "\\Seen";
  fileinto "Sent";
}
----------------------------------------------------------------------

My question is why the first one does not work? Does the email has been
moved to the Sent folder, and dovecot sieve plugin is not able to find
the email any more?

Kind regards,
André

-- 
https://github.com/progmaticltd/homebox


More information about the dovecot mailing list