• Debian 11 is approaching its end-of-life (vendor EOL date - August 31, 2026). Plesk Obsidian 18.0.80 will be the last release to support it.
    If you are running Plesk Obsidian on Debian 11, we recommend you upgrade those servers to Debian 12 using our dist-upgrade tool.
  • We plan to deprecate and remove the support for XML RPC protocol versions earlier than 1.6.9.1 in Plesk Obsidian 18.0.82. We strongly recommend that you update all existing integrations using earlier versions of the XML RPC protocol to comply with the version 1.6.9.1 specification.

Question How to prepend [EXT] to external emails (Postfix/SpamAssassin/Sieve)

tessa67

New Pleskian
Server operating system version
Debian 11
Plesk version and microupdate number
18.0.80 #3
Hello everyone,

using the configuration specified in my signature, I would like to prepand an "[EXT]" to the subject line of external emails, or write "EXTERNAL" at the very beginning of the email body.

All my attempts using header_checks, SpamAssassin, and Sieve have failed so far, and I am starting to wonder if this is even possible with my setup.

The domains examplea.com, exampleb.com, and examplec.com are internal email domains. Emails between these domains should remain untouched.
 
Sieve should be the right tools for this. You'll need some additional Dovecot configuration if you want the subject to be changed server wide for all mailboxes. If you want this just for one (or a couple) mailboxes than you can just apply a Sieve filter script for those specific mailboxes mailboxes. Roundcube for example let's you modify filter rules for a specific mailbox.

Sieve filter example script:
Code:
require ["editheader", "variables", "envelope"];

if allof (
    envelope :domain :is "to"
        ["examplea.com", "exampleb.com", "examplec.com"],

    not address :domain :is "From"
        ["examplea.com", "exampleb.com", "examplec.com"],

    not header :matches "Subject" "[EXT]*"
) {
    if header :matches "Subject" "*" {
        set "original_subject" "${1}";

        deleteheader "Subject";
        addheader "Subject" "[EXT] ${original_subject}";
    }
    else {
        # Handle messages without a Subject header.
        addheader "Subject" "[EXT]";
    }
}
* I've not tested this Sieve filter script, test first and use with caution.
 
Thank you very much! It works with sieve.

/etc/dovecot/sieve.d/10-external-tag.sieve
Code:
require ["editheader", "variables", "regex"];

if not header :regex "From" "@(examplea\.com|exampleb\.com|examplec\.com)" {

    if not header :contains "Subject" "[EXT]" {

        if header :matches "Subject" "*" {
            deleteheader "Subject";
            addheader :last "Subject" "[EXT] ${1}";
        }
    }
}

/etc/dovecot/conf.d/95-custom-sieve.conf
Code:
sieve_extensions {
  editheader = yes
  variables = yes
}

sieve_script custom_before {
  path = /etc/dovecot/sieve.d/10-external-tag.sieve
  type = before
}
 
Back
Top