Here is the relevant part of my sieve rule. Just know that you can switch the :contains to :is this would make it so the localpart would have to match the sender domain exactly. I'd do this but I initially wasn't using the full dns name for my localparts:
# Account sorting
set "domain_name" "acct.ninja";
if address :domain "To" "${domain_name}" {
if address :localpart :matches "To" "+" {
set :lower :upperfirst "addr" "${1}";
set :lower :upperfirst "subaddr" "${2}";
if not address :domain :contains "From" "${addr}" {
fileinto :create "SPAM";
} else {
fileinto :create "INBOX.Accounts.${addr}.${subaddr}";
}
stop;
} elsif address :localpart :matches "To" "*" {
set :lower :upperfirst "addr" "${1}";
if not address :domain :contains "From" "${addr}" {
fileinto :create "SPAM";
} else {
fileinto :create "INBOX.Accounts.${addr}";
}
stop;
}
}
Very interesting! I hadn't thought of having specific folders by the tag. I'll have to look carefully at my incoming mail and see how I can adapt this. Thanks!