Re: Insert a message for outside Emails?

Дилян Палаузов <[email protected]> Fri, 29 Aug 2025 20:41:07 +0300
Newsgroups gmane.mail.imap.cyrus
Message-ID <[email protected]>

Hello,

You can check with the sieve index extension if a particular Received: header (e.g. the third top most, depending on your setup) has received a message from inside or from outside, based on some regular expressions.  This check could also be done based on From header, or envelope sender.  (But the last two variants can be faked, unless you use DMARC).

Once a Sieve script determines that a message is from outside, 
• it can add a header (with the editheader extension), or
• set a flag like \\Flagged, or 
• move the message to a sub-mailbox(directory).
• You can also try to use variables, store in a variable the subject of the email, remove the subject header, prepend text to it, and add the new subject.  This breaks however DMARC/DKIM, if at any moment later is decided to evaluate DKIM again.

I do not think it is possible to prepend text to the message body.  This is hard to implement, if the message has three alternative MIME parts - icalendar, text, html - prepending text in HTML is hard, and prepending text in iCalendar is ... something very new.  But it is not clear which MIME part out of all alternatives the use wiil open, so you are asking to prepend text in all alternative MIME parts.


Concerning your other message about vacation not sent, when vacation messages are sent, an entry in the deliver.db database is made - https://www.cyrusimap.org/imap/concepts/deployment/databases.html#duplicate-delivery-deliver-db - to track when for last time a vacation message was sent.  You can look there if there are entries.  If sieve REJECT does not work for you, this means that Cyrus IMAP is not configured to send emails and for this reason it does not send vacation/out-of-office
responses.

From your examples:

> anyof(address :contains ["To","TO","Cc","CC"] "[email protected]", address :contains ["To","TO","Cc","CC"] "[email protected]")

You probably want to rewrite the above to the equivalent - see https://datatracker.ietf.org/doc/html/rfc5228.html#section-5.1 - 

> address :contains ["To", "Cc"] ["[email protected]", "[email protected]"]

and use instead of :contains → :is (or the lack of [MATCH-TYPE], which implies :is) 

Greetings // Дилян

-----Original Message-----
From: Dr. Thorsten Brandau via Info <[email protected]>
Reply-To: Info <[email protected]>
To: [email protected]
Subject: Insert a message for outside Emails?
Date: 28/08/25 19:30:17

I am looking at various sieve folders and wonder if anyone tried to 
create a filter that inserts a message like "Email from Outside Adresse" 
at the beginning of each message body, if the sender domain does not 
match the local one.

Is that possible?

I am getting my emails via fetchmails -> postfix -> cyrus, so something 
in postfix itself would not work.

Cheers

TB


------------------------------------------
Cyrus: Info
Permalink: https://cyrus.topicbox.com/groups/info/T4061c7db816fcf5c-Mfa1ed01a2531d5440cfdb680
Delivery options: https://cyrus.topicbox.com/groups/info/subscription