[Sieve] Multiple email recipients, how?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[Sieve] Multiple email recipients, how?

Dovecot mailing list
Hi,

First, I am very new to using Pigeonhole/Sieve with Dovecot and I am
struggling with a problem which could be easy to solve but is just a
lack of understanding on my end...

We use a simple system for routing emails to different email users by
postfixing the addresses with the actual user: xxxJohn@domain;
yyyJohn@domain etc all will be delivered to user John.
(This way John can invent a new email address on-the-fly and that will
be delivered to his email box.)
Delivering these emails to the right mailbox is easy:  if address
:contains "to" "John" ...
All mail not matched will go to the general (catchall) mail box.

The problem occurs when the email is sent to more addresses at the same
domain.  Eg. if an email is sent to xxxJohn@domain, zzzAlex@domain and
info@domain
Either, all emails also end up in the catch-all, or the email is
delivered to the first matching rule only.

I do not understand how to use the different TO addresses in the match
rules. How can I determine that there are recipients other than xxxJohn
or zzzAlex?

Any help in pointing me in the right direction is appreciated!

Robert

Reply | Threaded
Open this post in threaded view
|

Re: [Sieve] Multiple email recipients, how?

Dovecot mailing list
* Robert via dovecot:

> We use a simple system for routing emails to different email users by
> postfixing the addresses with the actual user: xxxJohn@domain;
> yyyJohn@domain etc all will be delivered to user John.
> (This way John can invent a new email address on-the-fly and that will
> be delivered to his email box.)

This seems like a strange way achieve flexible email addresses. Are you
aware of sub-addressing? It has been around for ages, and is supported
by Dovecot (and Gmail, incidentally).

Imagine an existing email account <[hidden email]>. If alice wants to
use a subadress, she signs up with <[hidden email]>, and Dovecot
can automatically place incoming mail for that address into INBOX/foo
(or just INBOX if INBOX/foo does not exist). Alice can use as many
sub-adresses as she needs without anybody making config changes.

Frankly, the Sieve-based approach you describe seems pretty complicated
in comparison.

-Ralph
Reply | Threaded
Open this post in threaded view
|

Re: [Sieve] Multiple email recipients, how?

Dovecot mailing list


On 22-11-19 22:48, Ralph Seichter via dovecot wrote:

> * Robert via dovecot:
>
>> We use a simple system for routing emails to different email users by
>> postfixing the addresses with the actual user: xxxJohn@domain;
>> yyyJohn@domain etc all will be delivered to user John.
>> (This way John can invent a new email address on-the-fly and that will
>> be delivered to his email box.)
>
> This seems like a strange way achieve flexible email addresses. Are you
> aware of sub-addressing? It has been around for ages, and is supported
> by Dovecot (and Gmail, incidentally).
>
> Imagine an existing email account <[hidden email]>. If alice wants to
> use a subadress, she signs up with <[hidden email]>, and Dovecot
> can automatically place incoming mail for that address into INBOX/foo
> (or just INBOX if INBOX/foo does not exist). Alice can use as many
> sub-adresses as she needs without anybody making config changes.
>
> Frankly, the Sieve-based approach you describe seems pretty complicated
> in comparison.
>

 From the OP it seems that they separate mail for different users not at
the MTA level, but at at the user level using sieve. That seems very
inefficient to me.

There are nice tricks you can do with virtual alias maps and pcre within
postfix to split email to specific user accounts, which could also
accommodate other alias schemes than standard subaddressing (such as yours).

Kind regards,
        Tom
Reply | Threaded
Open this post in threaded view
|

Re: [Sieve] Multiple email recipients, how?

Dovecot mailing list
In reply to this post by Dovecot mailing list
On 2019-11-22, Ralph Seichter via dovecot <[hidden email]> wrote:
> * Robert via dovecot:
>
>> We use a simple system for routing emails to different email users by
>> postfixing the addresses with the actual user: xxxJohn@domain;
>> yyyJohn@domain etc all will be delivered to user John.
>> (This way John can invent a new email address on-the-fly and that will
>> be delivered to his email box.)

But now you can't have a username like "BigJohn@domain". To avoid this
problem a separator character of some sort (that isn't used in a normal
email address at your site) is really wanted.

> This seems like a strange way achieve flexible email addresses. Are you
> aware of sub-addressing? It has been around for ages, and is supported
> by Dovecot (and Gmail, incidentally).
>
> Imagine an existing email account <[hidden email]>. If alice wants to
> use a subadress, she signs up with <[hidden email]>, and Dovecot
> can automatically place incoming mail for that address into INBOX/foo
> (or just INBOX if INBOX/foo does not exist). Alice can use as many
> sub-adresses as she needs without anybody making config changes.

This method works well, but the separator character can be a problem.
"+" is traditional, but is widely blocked by website validators -
if you can use "-" or "." instead they're much more likely to be
accepted.


Reply | Threaded
Open this post in threaded view
|

Re: [Sieve] Multiple email recipients, how?

Dovecot mailing list
In reply to this post by Dovecot mailing list
On 22 Nov 2019, at 14:48, Ralph Seichter <[hidden email]> wrote:

> * Robert via dovecot:
>
>> We use a simple system for routing emails to different email users by
>> postfixing the addresses with the actual user: xxxJohn@domain;
>> yyyJohn@domain etc all will be delivered to user John.
>> (This way John can invent a new email address on-the-fly and that will
>> be delivered to his email box.)
>
> This seems like a strange way achieve flexible email addresses. Are you
> aware of sub-addressing? It has been around for ages, and is supported
> by Dovecot (and Gmail, incidentally).

Seconded, this is the way to go.

> Imagine an existing email account <[hidden email]>. If alice wants to
> use a subadress, she signs up with <[hidden email]>, and Dovecot
> can automatically place incoming mail for that address into INBOX/foo
> (or just INBOX if INBOX/foo does not exist). Alice can use as many
> sub-adresses as she needs without anybody making config changes.

Far too many web monkeys seem to get their email validation coede from the same inept repository somewhere, and return error that “+” is not allowed in email addresses. The larger the company, the more likely they are to be incompetent, so I have setup my dovecot and postfix to use two legal delimiters, + and _

> Frankly, the Sieve-based approach you describe seems pretty complicated
> in comparison.

And prone to failure.

[hidden email]
[hidden email]
[hidden email]

Use address extensions. This is all that is required to setup two delimiters:

/etc/postfix/main.cf
recipient_delimiter = +_

/etc/dovecot/dovecot.conf
protocol lmtp {
  …
  recipient_delimiter = +_
}


--
Yeah, and I never wanted to kick Albert Einstein in the nuts.

Reply | Threaded
Open this post in threaded view
|

Re: [Sieve] Multiple email recipients, how?

Dovecot mailing list
In reply to this post by Dovecot mailing list
* Tom Hendrikx via dovecot:

> There are nice tricks you can do with virtual alias maps and pcre
> within postfix to split email to specific user accounts, which could
> also accommodate other alias schemes than standard subaddressing (such
> as yours).

Postfix supports sub-addressing out of the box, simply by setting the
"recipient_delimiter" configuration parameter[1].

-Ralph

[1] http://www.postfix.org/postconf.5.html#recipient_delimiter
Reply | Threaded
Open this post in threaded view
|

Re: [Sieve] Multiple email recipients, how?

Dovecot mailing list
I do know that sub-addressing with a special character is nowadays a
normal, better, way to do it.
Unfortunately we have used this system for a very long time, starting
around 2005... So there are a lot of existing email addresses.

I am considering changing to a new hosting company, that's why I started
looking for a solution.  The current company has very limited
functionality for filtering using a simple webinterface, but the system
I described works. The new hosting company uses all the nice features
that brought me to this mailing list and I just want to find a solution
for the existing email addresses. (We will switch to proper
sub-addressing for new emailaddresses if I switch to the new hosting)

 From what I understand there is no easy solution for solving this at
the MTA level, and at the user level it is not easy to differentiate
between multiple recipients?

I have been trying different approaches (like regexes using (?!john),
which I couldn't get to work) and belo is hat I came up with so far.
The problem with this is that all emails to multiple recipients still
end up in the general mailbox, but emails send only to one recipient
works ok.
Any suggestions on improving? Or a completely different approach?

--Robert

if address :contains ["to","cc"] "john@<domain>"
{
     # only one recipient
     if address :count "eq" :comparator "i;ascii-numeric" ["to","cc"] "1"
     {
         #redirect or fileinto
         redirect "[hidden email]";
         stop;
     }
     else{
         #redirect or fileinto and continue with next filter
         redirect :copy "[hidden email]";
     }
}


Ralph Seichter schreef op 23-11-2019 om 18:40:

> * Tom Hendrikx via dovecot:
>
>> There are nice tricks you can do with virtual alias maps and pcre
>> within postfix to split email to specific user accounts, which could
>> also accommodate other alias schemes than standard subaddressing (such
>> as yours).
> Postfix supports sub-addressing out of the box, simply by setting the
> "recipient_delimiter" configuration parameter[1].
>
> -Ralph
>
> [1] http://www.postfix.org/postconf.5.html#recipient_delimiter

Reply | Threaded
Open this post in threaded view
|

Re: [Sieve] Multiple email recipients, how?

Dovecot mailing list
On 23 Nov 2019, at 13:50, Robert <[hidden email]> wrote:
> I do know that sub-addressing with a special character is nowadays a normal, better, way to do it.
> Unfortunately we have used this system for a very long time, starting around 2005... So there are a lot of existing email addresses.

Then set them up in virtual (or if not using postfix, whatever equivalent) and stop allowing new ones.

This is FAR simpler and workable than what you are trying to do, and has the added benefit of working very simply and having nearly no impact on your server.


--
NON-FLAMMABLE IS NOT A CHALLENGE Bart chalkboard Ep. BABF13

Reply | Threaded
Open this post in threaded view
|

Re: [Sieve] Multiple email recipients, how?

Dovecot mailing list
I think you mean collecting all email addresses and connecting them
(manually) to the correct mailbox in the config of Postfix (or equiv, I
have no idea what is used at my hosting provider)? That sounds like a
doable one-time action if all new addresses use proper sub-addressing.


@lbutlr schreef op 23-11-2019 om 22:56:
> On 23 Nov 2019, at 13:50, Robert <[hidden email]> wrote:
>> I do know that sub-addressing with a special character is nowadays a normal, better, way to do it.
>> Unfortunately we have used this system for a very long time, starting around 2005... So there are a lot of existing email addresses.
> Then set them up in virtual (or if not using postfix, whatever equivalent) and stop allowing new ones.
>
> This is FAR simpler and workable than what you are trying to do, and has the added benefit of working very simply and having nearly no impact on your server.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: [Sieve] Multiple email recipients, how?

Dovecot mailing list
On 23 Nov 2019, at 15:40, Robert <[hidden email]> wrote:
> I think you mean collecting all email addresses and connecting them (manually) to the correct mailbox in the config of Postfix (or equiv, I have no idea what is used at my hosting provider)? That sounds like a doable one-time action if all new addresses use proper sub-addressing.

I didn’t realize you did not have control of your Mailserver.

Still, the sooner you get off the method you are using the better off everyone is going to be, I wouldn’t count on a mail server not noticing your multiple forwarding to different addresses and putting a stop to it, as it is resource intensive.

If you have access to create new email addresses you also probably have access to create aliases as well.

# Outside address       ALIASED TO     INSIDE ADDRESS
[hidden email]     =>          [hidden email]
[hidden email]     =>          [hidden email]
[hidden email]       =>          [hidden email]
[hidden email]   =>          [hidden email]
Etc etc

This removes the need to sieve scripts that try to parse the from.


--
I noticed that but was still trying to work out a way of drawing it to
everyone's attention that would be sufficiently satisfying, combining
maximum entertainment value for readers with maximum humiliation for you.
   — Laura

Reply | Threaded
Open this post in threaded view
|

Re: [Sieve] Multiple email recipients, how?

Dovecot mailing list
In reply to this post by Dovecot mailing list


On 23-11-19 18:40, Ralph Seichter via dovecot wrote:

> * Tom Hendrikx via dovecot:
>
>> There are nice tricks you can do with virtual alias maps and pcre
>> within postfix to split email to specific user accounts, which could
>> also accommodate other alias schemes than standard subaddressing (such
>> as yours).
>
> Postfix supports sub-addressing out of the box, simply by setting the
> "recipient_delimiter" configuration parameter[1].
>
> -Ralph
>
> [1] http://www.postfix.org/postconf.5.html#recipient_delimiter
>
Standard subaddressing is not able to support the addressing scheme the
OP has in place. But there are other ways, such as pcre alias maps, that
will solve his problem a lot easier than Sieve address parsing, without
discarding the existing (albeit peculiar) subaddressing scheme. I just
wanted to make sure that the OP was aware of this.

Kind regards,
        Tom