Sieve Subaddressing Rule #28

Closed
opened 1 year ago by moon · 4 comments
moon commented 1 year ago

Hi there, I saw that subaddressing can be setup for custom domains on Purelymail. I'm completely new to Sieve so I might have the script wrong. But with the below it wasn't working and I was getting Postmaster bounces saying "550 - Requested action note taken: no such user here"

require ["variables", "envelope", "fileinto", "subaddress"];

# Subaddressing mydomain.com
if envelope :domain "To" "mydomain.com" {
    if envelope :matches :detail "to" "*" {
        /* Save name in ${name} in all lowercase except for the first letter.
         * Joe, joe, jOe thus all become 'Joe'.
         */
        set :lower :upperfirst "name" "${1}";
    }
    
    if string :is "${name}" "" {
        /* Default case if no detail is specified */
        fileinto "Inbox";
    } else {
        /* For sales+joe@ this will become users/Joe */
        fileinto :create "${name}";
    }
}
Hi there, I saw that subaddressing can be setup for custom domains on Purelymail. I'm completely new to Sieve so I might have the script wrong. But with the below it wasn't working and I was getting Postmaster bounces saying "550 - Requested action note taken: no such user here" ``` require ["variables", "envelope", "fileinto", "subaddress"]; # Subaddressing mydomain.com if envelope :domain "To" "mydomain.com" { if envelope :matches :detail "to" "*" { /* Save name in ${name} in all lowercase except for the first letter. * Joe, joe, jOe thus all become 'Joe'. */ set :lower :upperfirst "name" "${1}"; } if string :is "${name}" "" { /* Default case if no detail is specified */ fileinto "Inbox"; } else { /* For sales+joe@ this will become users/Joe */ fileinto :create "${name}"; } } ```
Owner

I think your script is correct, but you don't have a redirect action. So it will file into the right mailbox, but it still won't find the user whose mailbox it is.

Assuming your filter is account-wide, something like this:

if envelope :matches :user "to" "*" {
    set "user" "${1}";
}
if envelope :matches :domain "to" "*" {
    set "domain" "${1}";
}
redirect "${user}@${domain}";

(By the way, it might be easier to compose the filter in webmail for a user and then use the "Download" to get the raw script. I'm not actually super great with Sieve either, which is why I plan to build a nice editor for account routing)

I think your script is correct, but you don't have a redirect action. So it will file into the right mailbox, but it still won't find the user whose mailbox it is. Assuming your filter is account-wide, something like this: ``` if envelope :matches :user "to" "*" { set "user" "${1}"; } if envelope :matches :domain "to" "*" { set "domain" "${1}"; } redirect "${user}@${domain}"; ``` (By the way, it might be easier to compose the filter in webmail for a user and then use the "Download" to get the raw script. I'm not actually super great with Sieve either, which is why I plan to build a nice editor for account routing)
moon commented 1 year ago
Poster

Ah that helped. I now get the email in my inbox but I still get an email in the inbox of the sender from Postmaster giving the same 550 - Requested action not taken: no such user here

Ah that helped. I now get the email in my inbox but I still get an email in the inbox of the sender from Postmaster giving the same `550 - Requested action not taken: no such user here`
Owner

Oh man, I just realized I didn't think through the fileinto action in an account sieve script.

Basically, like a user sieve script, combining redirect with fileinto actually results in two emails; one will try to fileinto the specified mailbox on the user+foo@domain address, and the other will actually redirect (but not preserve the mailbox from fileinto) to user@domain.

I need to rework this to make it have sensible analogous behavior, which could take a bit. It's an obvious extension of Sieve scripts for routing across a domain IMO, but not one that's standardized.

For your current use case if you don't need the fileinto part on too many users, I'd recommend you use the webmail interface under Settings -> Filters, then create and "edit filter set", which should let you edit it as a Sieve script for the fileinto part of the script. The redirect part can stay in your account filter.

Oh man, I just realized I didn't think through the fileinto action in an account sieve script. Basically, like a user sieve script, combining redirect with fileinto actually results in two emails; one will try to fileinto the specified mailbox on the user+foo@domain address, and the other will actually redirect (but not preserve the mailbox from fileinto) to user@domain. I need to rework this to make it have sensible analogous behavior, which could take a bit. It's an obvious extension of Sieve scripts for routing across a domain IMO, but not one that's standardized. For your current use case if you don't need the fileinto part on too many users, I'd recommend you use the webmail interface under Settings -> Filters, then create and "edit filter set", which should let you edit it as a Sieve script for the fileinto part of the script. The redirect part can stay in your account filter.
moon commented 1 year ago
Poster

Thanks Scott. Understood! Thanks for all the help!

Thanks Scott. Understood! Thanks for all the help!
moon closed this issue 1 year ago
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.