Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-17 Thread Beau Ford




On Sun, 17 Apr 2022, Reio Remma wrote:


... and the same is true if I remove the space between the commas:


action "tones" mbox virtual { "to...@domain.com" = user1,user2 }



Did you try the exact example Gilles gave? With quoted { u...@domain.com = 
"user1, user2"} ?



I just tried that ... and it works :)   No syntax errors.

So I do *not* need to process "aliases" with multiple recipients in 
procmail, I can do it right in smtpd.conf with:



action "tones" mbox virtual { "to...@domain.com" = "user1, user2" }


Thanks!



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-17 Thread Reio Remma

On 17.04.2022 21:39, Beau Ford wrote:


On Sat, 16 Apr 2022, gil...@poolp.org wrote:

Hope the example above helps someone in the future. If future 
readers wonder how I handle multiple
recipients for a single alias, I just cc: the second or third 
recipient in .procmailrc ... so the

normal alias syntax of:

user joe,billy,bob

... is not actually possible ... I have to achieve that with procmail.



are you sure ?

I can't test right now but I don't see a reason why { u...@domain.com 
= "joe,billy,bob" }
would not work, if it really doesn't that may be a mistake on your 
side or a bug on

OpenSMTPD's




I can confirm ... this line works fine:


action "tones" mbox virtual { "to...@domain.com" = user1 }


... but if I change it to:


action "tones" mbox virtual { "to...@domain.com" = user1, user2 }


... I get:


Performing sanity check on smtpd configuration:
/usr/local/etc/mail/smtpd.conf:42: syntax error
/usr/local/etc/mail/smtpd.conf:62: no such dispatcher: tones


... and the same is true if I remove the space between the commas:


action "tones" mbox virtual { "to...@domain.com" = user1,user2 }



Did you try the exact example Gilles gave? With quoted { u...@domain.com 
= "user1, user2"} ?


Good luck
Reio



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-17 Thread Beau Ford




On Sat, 16 Apr 2022, gil...@poolp.org wrote:


Hope the example above helps someone in the future. If future readers wonder 
how I handle multiple
recipients for a single alias, I just cc: the second or third recipient in 
.procmailrc ... so the
normal alias syntax of:

user joe,billy,bob

... is not actually possible ... I have to achieve that with procmail.



are you sure ?

I can't test right now but I don't see a reason why { u...@domain.com = 
"joe,billy,bob" }
would not work, if it really doesn't that may be a mistake on your side or a 
bug on
OpenSMTPD's




I can confirm ... this line works fine:


action "tones" mbox virtual { "to...@domain.com" = user1 }


... but if I change it to:


action "tones" mbox virtual { "to...@domain.com" = user1, user2 }


... I get:


Performing sanity check on smtpd configuration:
/usr/local/etc/mail/smtpd.conf:42: syntax error
/usr/local/etc/mail/smtpd.conf:62: no such dispatcher: tones


... and the same is true if I remove the space between the commas:


action "tones" mbox virtual { "to...@domain.com" = user1,user2 }



Thanks.



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-16 Thread gilles
April 16, 2022 2:50 AM, "Beau Ford"  wrote:

> Gilles,
> 
> Thank you for the time and energy you have spent on this. I appreciate it.
> 

You're welcome :-)


> On Fri, 15 Apr 2022, gil...@poolp.org wrote:
> 
>> Sorry but on a second thought, this is wrong for several reasons.
>> 
>> The main one is that aliases transforms recipient addresses BEFORE they are 
>> matched
>> to a local user, so imagine you have something like:
> 
> OK, that answers my original, fundamental question: why aren't there 
> wildcards / catchalls in
> aliases. Now I know. Thanks!
> 
>> If I were you, I'd try to fit my use-case in virtual rather than aliases as 
>> this is
>> the mechanism intended for what you're trying to do. I had a look at Postfix 
>> and if
>> I'm not mistaken they also have catchall part of virtual rather than 
>> aliases, which
>> would likely be for the same reasons.
> 
> OK.
> 
> I worked up an alternative ... I actually only have four aliases so I 
> hardcoded them into the conf
> file like this:
> 
> # plain old unix usernames
> action "users" mbox
> 
> # aliases
> action "abuse" mbox virtual { "ab...@domain.com" = postmaster }
> action "reminders" mbox virtual { "remind...@domain.com" = username }
> 
> # catchall
> action "catchall" mbox virtual { "@domain.com" = username }
> 
> # explicit match rule for every unix user - all use the "users" action
> 
> match from any for any rcpt-to "u...@domain.com" action "users"
> match from any for any rcpt-to "us...@domain.com" action "users"
> match from any for any rcpt-to "us...@domain.com" action "users"
> 
> # Next come the aliases
> 
> match from any for any rcpt-to "ab...@domain.com" action "abuse"
> match from any for any rcpt-to "remind...@domain.com" action "reminders"
> 
> # Last is the catchall
> 
> match from any for domain "domain.com" action "catchall"
> 
> This is weird and ugly but I am pleased with the actual result - are there 
> any dangers or pitfalls
> here that I am not noticing ?
> 

not really, but is there a reason you don't merge them as such?

action "users" mbox
action "local_deliver" mbox virtual { "ab...@domain.com" = postmaster, 
"remind...@domain.com" = username, "@domain.com" = username }

match from any for any rcpt-to { "u...@domain.com", "us...@domain.com", 
"us...@domain.com" } action "users"
match from any for any rcpt-to "@domain.com" action "local_deliver"


or even as such (untested but so you get the idea):

table "vdom" { "us...@domain.com" = user1, "us...@domain.com" = user2, 
"us...@domain.com" = user3, "ab...@domain.com" = postmaster, 
"remind...@domain.com" = username, "@domain.com" = username }

action "local_deliver" mbox virtual 

match from any for any rcpt-to  action 


or as such if you only have a single domain:

table "vdom" { "user1" = "user1", "user2" = "user2", "user3" = "user3", "abuse" 
= "postmaster", "reminders" = "username", "@domain.com" = username }
action "local_deliver" mbox virtual 

match from any for any domain "domain.com" rcpt-to  action 


I'd use a file to back the table too as this allows updating it and calling 
`smtpctl update table vdom`,
rather than having to restart the daemon to update the list of users:

table "vdom" file:/etc/mail/vdom




> Hope the example above helps someone in the future. If future readers wonder 
> how I handle multiple
> recipients for a single alias, I just cc: the second or third recipient in 
> .procmailrc ... so the
> normal alias syntax of:
> 
> user joe,billy,bob
> 
> ... is not actually possible ... I have to achieve that with procmail.
> 

are you sure ?

I can't test right now but I don't see a reason why { u...@domain.com = 
"joe,billy,bob" }
would not work, if it really doesn't that may be a mistake on your side or a 
bug on
OpenSMTPD's



> Thanks!
> 
> P.S. YES, I did indeed waste two hours on that thing where the rule is 
> written:
> 
> match from any rcpt-to "gil...@poolp.org" action "out"
> 
> ... but it should be:
> 
> match from any for any rcpt-to "gil...@poolp.org" action "out"


look at the bright side, the reaosn why you wasted two hours is because it 
tried hard
not to let you create a relay that was too open :-]



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-15 Thread Beau Ford




Gilles,


Thank you for the time and energy you have spent on this.  I appreciate 
it.




On Fri, 15 Apr 2022, gil...@poolp.org wrote:


Sorry but on a second thought, this is wrong for several reasons.

The main one is that aliases transforms recipient addresses BEFORE they are 
matched
to a local user, so imagine you have something like:



OK, that answers my original, fundamental question:  why aren't there 
wildcards / catchalls in aliases.  Now I know.  Thanks!





If I were you, I'd try to fit my use-case in virtual rather than aliases as 
this is
the mechanism intended for what you're trying to do. I had a look at Postfix 
and if
I'm not mistaken they also have catchall part of virtual rather than aliases, 
which
would likely be for the same reasons.




OK.

I worked up an alternative ... I actually only have four aliases so I 
hardcoded them into the conf file like this:




# plain old unix usernames
action "users" mbox

# aliases
action "abuse" mbox virtual { "ab...@domain.com" = postmaster }
action "reminders" mbox virtual { "remind...@domain.com" = username }

# catchall
action "catchall" mbox virtual { "@domain.com" = username }



# explicit match rule for every unix user - all use the "users" action

match from any for any rcpt-to "u...@domain.com" action "users"
match from any for any rcpt-to "us...@domain.com" action "users"
match from any for any rcpt-to "us...@domain.com" action "users"


# Next come the aliases

match from any for any rcpt-to "ab...@domain.com" action "abuse"
match from any for any rcpt-to "remind...@domain.com" action "reminders"

# Last is the catchall

match from any for domain "domain.com" action "catchall"





This is weird and ugly but I am pleased with the actual result - are there 
any dangers or pitfalls here that I am not noticing ?



Hope the example above helps someone in the future.  If future readers 
wonder how I handle multiple recipients for a single alias, I just cc: the 
second or third recipient in .procmailrc ... so the normal alias syntax 
of:


userjoe,billy,bob


... is not actually possible ... I have to achieve that with procmail.




Thanks!




P.S.  YES, I did indeed waste two hours on that thing where the rule is 
written:



match from any rcpt-to "gil...@poolp.org" action "out"


... but it should be:


match from any for any rcpt-to "gil...@poolp.org" action "out"



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-15 Thread Edgar Pettijohn



On 4/14/22 14:00, Beau Ford wrote:



On Thu, 14 Apr 2022, Beau Ford wrote:



1) Am I still using my aliases that are defined in:

table aliases file:/usr/local/etc/mail/aliases
action "local_mail" mbox alias 

... or are those superceded now by the catchall ?



It turns out I am *not* using my aliases anymore and that my rules, as
they are written, are mutually exclusive.

If I order them like this:


    match from any for domain "domain.com" action "local_mail"
    match from any for domain "domain.com" action "catchall"


... then my aliases table is processed, like normal, and the catchall is
ignored.  This makes sense, because the rule matches and it completes -
there is no reason to move on to the catchall address.

Nonexistent addresses (that I hoped to get with the catchall) bomb out
with 550 Invalid recipient.


HOWEVER, if I reverse the order:


    match from any for domain "domain.com" action "catchall"
    match from any for domain "domain.com" action "local_mail"


... then the catch-all works and I lose all of my aliases.  My aliases
table is not used.  Again, makes sense - the first rule matches and
completes.


-


So, how can I say (pseudocode):

match from any person actually a user or in my aliases table action
"local_mail"


... which would fail for nonexistent addresses, which is GOOD, and then
successfully move down to the catchall match ?



Thanks.




I recall someone on the list trying to solve this problem awhile back. 
As I recall they needed to have a copy of all inbound emails saved for 
some reason or another. I think for their use case they had to run a 
second postfix instance to handle the catchall. Might be worth 
traversing the list archives.



Edgar




Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-15 Thread gilles
Sorry but on a second thought, this is wrong for several reasons.

The main one is that aliases transforms recipient addresses BEFORE they are 
matched
to a local user, so imagine you have something like:

root: gilles
@: gilles

If I send mail to e...@poolp.org and there's a local user eric, what should it 
do ?

Either you consider that local user eric should get it but this contradicts 
aliases
configuration as it now explicitly states that *@poolp.org should resolve to 
gilles
and, if that's what I really wanted, it would be the only way to express it.

Or you consider that gilles is supposed to get it but then it means that a 
catchall
will get mail for any recipient that is not listed in the aliases 
configuration. So
to receive mail for eric, you'd need to list him as such:

root: gilles
eric: eric
@: gilles

... and it turns domain aliases into virtual domains aliases as the main 
difference
between both is precisely that aliases are allowed to not resolve to a user 
whereas
virtual requires resolution to succeed.

You want a mechanism that has enough knowledge of the recipients to determine 
which
ones do not exist and should be handled by the catchall but aliases aren't 
meant to
do that: they are expectedly allowed to have missing keys for bypass.

If I were you, I'd try to fit my use-case in virtual rather than aliases as 
this is
the mechanism intended for what you're trying to do. I had a look at Postfix 
and if
I'm not mistaken they also have catchall part of virtual rather than aliases, 
which
would likely be for the same reasons.

Gilles



April 15, 2022 1:10 AM, gil...@poolp.org wrote:

> Forget about the whole fallback idea, it can't work because an envelope can 
> only
> successfully match a single rule for _very_ good reasons that are not related 
> to
> the implementation itself but to how SMTP works more generally. The ruleset 
> does
> a first-match evaluation and once it found a rule that matched, that is the 
> only
> rule it can consider for that envelope otherwise TONS of unfixable issues 
> arise.
> I can explain if there's interest, but it's very technical and unrelated to 
> your
> issue.
> 
> The only reason you are trying to fallback is because aliases_get() did not 
> have
> the same wildcard logic as virtual_get(), otherwise with a configuration like:
> 
> match from any for domain "domain.com" action "local_mail"
> 
> and an alias record of "@: username" (or an inlined { "@" = username }), the 
> use
> case you have is solved without having to think about a fallback rule.
> 
> Care to try the following diff ?
> 
> Index: aliases.c
> ===
> RCS file: /cvs/src/usr.sbin/smtpd/aliases.c,v
> retrieving revision 1.78
> diff -u -p -r1.78 aliases.c
> --- aliases.c 28 Apr 2020 21:46:43 - 1.78
> +++ aliases.c 14 Apr 2022 22:40:24 -
> @@ -66,8 +66,15 @@ aliases_get(struct expand *expand, const
> 
> /* no user-part tag, try looking up user */
> ret = table_lookup(mapping, K_ALIAS, buf, &lk);
> + if (ret < 0)
> + return (-1);
> + if (ret)
> + goto expand;
> +
> + /* Failed ? We lookup for a *global* catch all */
> + ret = table_lookup(mapping, K_ALIAS, "@", &lk);
> if (ret <= 0)
> - return ret;
> + return (ret);
> 
> expand:
> /* foreach node in table_alias expandtree, we merge */
> 
> April 14, 2022 9:00 PM, "Beau Ford"  wrote:
> 
>> On Thu, 14 Apr 2022, Beau Ford wrote:
> 
> 1) Am I still using my aliases that are defined in:
> 
> table aliases file:/usr/local/etc/mail/aliases
> action "local_mail" mbox alias 
> 
> ... or are those superceded now by the catchall ?
>> It turns out I am *not* using my aliases anymore and that my rules, as
>> they are written, are mutually exclusive.
>> 
>> If I order them like this:
>> 
>> match from any for domain "domain.com" action "local_mail"
>> match from any for domain "domain.com" action "catchall"
>> 
>> ... then my aliases table is processed, like normal, and the catchall is
>> ignored. This makes sense, because the rule matches and it completes -
>> there is no reason to move on to the catchall address.
>> 
>> Nonexistent addresses (that I hoped to get with the catchall) bomb out
>> with 550 Invalid recipient.
>> 
>> HOWEVER, if I reverse the order:
>> 
>> match from any for domain "domain.com" action "catchall"
>> match from any for domain "domain.com" action "local_mail"
>> 
>> ... then the catch-all works and I lose all of my aliases. My aliases
>> table is not used. Again, makes sense - the first rule matches and
>> completes.
>> 
>> -
>> 
>> So, how can I say (pseudocode):
>> 
>> match from any person actually a user or in my aliases table action
>> "local_mail"
>> 
>> ... which would fail for nonexistent addresses, which is GOOD, and then
>> successfully move down to the catchall match ?



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-14 Thread gilles
Forget about the whole fallback idea, it can't work because an envelope can only
successfully match a single rule for _very_ good reasons that are not related to
the implementation itself but to how SMTP works more generally. The ruleset does
a first-match evaluation and once it found a rule that matched, that is the only
rule it can consider for that envelope otherwise TONS of unfixable issues arise.
I can explain if there's interest, but it's very technical and unrelated to your
issue.

The only reason you are trying to fallback is because aliases_get() did not have
the same wildcard logic as virtual_get(), otherwise with a configuration like:

match from any for domain "domain.com" action "local_mail"

and an alias record of "@: username" (or an inlined { "@" = username }), the use
case you have is solved without having to think about a fallback rule.

Care to try the following diff ?



Index: aliases.c
===
RCS file: /cvs/src/usr.sbin/smtpd/aliases.c,v
retrieving revision 1.78
diff -u -p -r1.78 aliases.c
--- aliases.c   28 Apr 2020 21:46:43 -  1.78
+++ aliases.c   14 Apr 2022 22:40:24 -
@@ -66,8 +66,15 @@ aliases_get(struct expand *expand, const
 
/* no user-part tag, try looking up user */
ret = table_lookup(mapping, K_ALIAS, buf, &lk);
+   if (ret < 0)
+   return (-1);
+   if (ret)
+   goto expand;
+
+   /* Failed ? We lookup for a *global* catch all */
+   ret = table_lookup(mapping, K_ALIAS, "@", &lk);
if (ret <= 0)
-   return ret;
+   return (ret);
 
 expand:
/* foreach node in table_alias expandtree, we merge */





April 14, 2022 9:00 PM, "Beau Ford"  wrote:

> On Thu, 14 Apr 2022, Beau Ford wrote:
> 
>> 1) Am I still using my aliases that are defined in:
>> 
>> table aliases file:/usr/local/etc/mail/aliases
>> action "local_mail" mbox alias 
>> 
>> ... or are those superceded now by the catchall ?
> 
> It turns out I am *not* using my aliases anymore and that my rules, as
> they are written, are mutually exclusive.
> 
> If I order them like this:
> 
> match from any for domain "domain.com" action "local_mail"
> match from any for domain "domain.com" action "catchall"
> 
> ... then my aliases table is processed, like normal, and the catchall is
> ignored. This makes sense, because the rule matches and it completes -
> there is no reason to move on to the catchall address.
> 
> Nonexistent addresses (that I hoped to get with the catchall) bomb out
> with 550 Invalid recipient.
> 
> HOWEVER, if I reverse the order:
> 
> match from any for domain "domain.com" action "catchall"
> match from any for domain "domain.com" action "local_mail"
> 
> ... then the catch-all works and I lose all of my aliases. My aliases
> table is not used. Again, makes sense - the first rule matches and
> completes.
> 
> -
> 
> So, how can I say (pseudocode):
> 
> match from any person actually a user or in my aliases table action
> "local_mail"
> 
> ... which would fail for nonexistent addresses, which is GOOD, and then
> successfully move down to the catchall match ?
>



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-14 Thread Beau Ford



On Thu, 14 Apr 2022, Thomas Bohl wrote:


     match from any for domain "domain.com" action "local_mail"
     match from any for domain "domain.com" action "catchall"


match for local action "local_mail"
match from any for domain "domain.com" action "catchall"



Tried this - thank you - but it is not a solution.

aliases should work for non-local mail ... and in this case, the alias 
match ("local_mail") only matches local mail ...



(I should rename that action to "aliases")

Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-14 Thread Thomas Bohl

     match from any for domain "domain.com" action "local_mail"
     match from any for domain "domain.com" action "catchall"


match for local action "local_mail"
match from any for domain "domain.com" action "catchall"


I hope I understood you correctly.
If not, merge the tables.



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-14 Thread Beau Ford




On Thu, 14 Apr 2022, Beau Ford wrote:



1) Am I still using my aliases that are defined in:

table aliases file:/usr/local/etc/mail/aliases
action "local_mail" mbox alias 

... or are those superceded now by the catchall ?



It turns out I am *not* using my aliases anymore and that my rules, as
they are written, are mutually exclusive.

If I order them like this:


match from any for domain "domain.com" action "local_mail"
match from any for domain "domain.com" action "catchall"


... then my aliases table is processed, like normal, and the catchall is
ignored.  This makes sense, because the rule matches and it completes -
there is no reason to move on to the catchall address.

Nonexistent addresses (that I hoped to get with the catchall) bomb out
with 550 Invalid recipient.


HOWEVER, if I reverse the order:


match from any for domain "domain.com" action "catchall"
match from any for domain "domain.com" action "local_mail"


... then the catch-all works and I lose all of my aliases.  My aliases
table is not used.  Again, makes sense - the first rule matches and
completes.


-


So, how can I say (pseudocode):

match from any person actually a user or in my aliases table action
"local_mail"


... which would fail for nonexistent addresses, which is GOOD, and then
successfully move down to the catchall match ?



Thanks.




Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-14 Thread Beau Ford




On Thu, 14 Apr 2022, gil...@poolp.org wrote:


I'm not active these days, but waking up because this thread is getting out of 
hands :-)




Thank you very much - this worked, but I have a follow-up clarification 
below ...





My goal is to add exactly one catchall rule and keep my config simple inside 
smtpd.conf without
dealing with virtual users and virtusertable, etc.



what you want is:

   action "catchall" mbox virtual { "@" = username }

   match from any for any action "catchall"



OK, this worked.  However, I originally had my 'match' rules in this 
order:



match tag DKIM for any action "outbound"
match from any for domain "domain.com" action "local_mail"
match from any for any action "catchall"
match from any auth for any action "outbound"
match for local action "local_mail"
match for any action "relay_dkim"


... and it failed ... weirdj...@domain.com produced 550 Invalid recipient.

So I changed the order to:


match tag DKIM for any action "outbound"
match from any for any action "catchall"
match from any for domain "domain.com" action "local_mail"
match from any auth for any action "outbound"
match for local action "local_mail"
match for any action "relay_dkim"


... and it works as expected - again, thank you.


Two follow-up questions:


1) Am I still using my aliases that are defined in:

table aliases file:/usr/local/etc/mail/aliases
action "local_mail" mbox alias 

... or are those superceded now by the catchall ?


2) Are any of my 'match' rules in that list redundant/unnecessary now that 
the catchall rule is match #2 ?



Thanks.





Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-14 Thread gilles
I'm not active these days, but waking up because this thread is getting out of 
hands :-)

Reponses inlined:

April 14, 2022 7:20 AM, "Beau Ford"  wrote:

> On Mon, 11 Apr 2022, Reio Remma wrote:
> 
>>> Am I misremembering or is that a possibility - to implement the '@' >> 
>>> catchall directly inside
>>> smtpd.conf without reference to lookup tables or >> virtusers (or aliases) 
>>> ? >
>> 
>> There's this format for inline tables:
>> 
>> table "barbaz" { foo = bar, baz = qux }
> 
> OK, I added this line to my (working) smtpd.conf:
> 
> table catchall { "@" = username }
> 
> ... so there is the static table ... and "username" is a real, actual UNIX 
> user in the passwd file.
> Not a virtual user.
> 

virtual means virtual domains, not virtual users:

https://www.mail-archive.com/misc@opensmtpd.org/msg04752.html



> Then I added this line:
> 
> accept for any virtual  deliver to mbox
> 
> ... and that line bombs out my configuration ... here is my entire 
> configuration *including* these
> two additional lines. This config works great if I remove the two new lines:
> 

That's not a valid rule for smtpd.conf, this syntax was that used pre-2018,
it should be rewritten as follows because actions and matching are now disjoint 
concepts:

action "foobar" mbox virtual 
match for any action "foobar"

> 
> My goal is to add exactly one catchall rule and keep my config simple inside 
> smtpd.conf without
> dealing with virtual users and virtusertable, etc.
> 

what you want is:

action "catchall" mbox virtual { "@" = username }

match from any for any action "catchall"

where username is the username of your local user that will catch all mails.
again, this is not virtual users as virtual does not mean what you think it 
means here,
virtual users are handled through the `userbase` option to provide an alternate 
userbase.

Note however that you should really add a catchall to domains, such as:

action "catchall" mbox virtual { "@poolp.org" = username }

or restrict the domains with an rcpt-to clause on the match rule:

match for rcpt-to { "@poolp.org" } action "catchall"

otherwise your MX will _seem_ to be an open-relay for some mailers since you're 
going to
be accepting mail for any domain even though you won't be relaying them 
afterwards. This
might still impact the reputation of your domain.

Cheers,



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-14 Thread Reio Remma

On 14.04.2022 08:44, Beau Ford wrote:


Reio,

On Thu, 14 Apr 2022, Reio Remma wrote:

... and that line bombs out my configuration ... here is my entire 
configuration *including* these two additional lines.  This config 
works great if I remove the two new lines:


How exactly? What's the error?



Performing sanity check on smtpd configuration:
/usr/local/etc/mail/smtpd.conf:30: syntax error

... and no other details.


The "accept" is old syntax and doesn't work anymore since version... 
I can't remember. :)


So you'll want an action that delivers to mbox and an accompanying 
match rule.



Do you mean, literally, an "action" - as in:


action ...


If so, that is confusing because I already have this line:


action "local_mail" mbox alias 


... which basically does all delivery for me ... would I augment that 
with something like:



action "local_mail" mbox alias  virtual 


... or issue that same line twice, but slightly different:


action "local_mail" mbox alias 
action "local_mail" mbox virtual 


Gilles' guide for the new syntax suggests you're on the right track.

https://poolp.org/posts/2018-05-21/switching-to-opensmtpd-new-config/

Unfortunately I've taken down my test OpenSMTPD server once my own 
configuration was settled, so I can't run any tests myself atm. :)


Good luck,
Reio



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-13 Thread Beau Ford


Reio,

On Thu, 14 Apr 2022, Reio Remma wrote:

... and that line bombs out my configuration ... here is my entire 
configuration *including* these two additional lines.  This config works 
great if I remove the two new lines:


How exactly? What's the error?



Performing sanity check on smtpd configuration:
/usr/local/etc/mail/smtpd.conf:30: syntax error

... and no other details.


The "accept" is old syntax and doesn't work anymore since version... I can't 
remember. :)


So you'll want an action that delivers to mbox and an accompanying match 
rule.



Do you mean, literally, an "action" - as in:


action ...


If so, that is confusing because I already have this line:


action "local_mail" mbox alias 


... which basically does all delivery for me ... would I augment that with 
something like:



action "local_mail" mbox alias  virtual 


... or issue that same line twice, but slightly different:


action "local_mail" mbox alias 
action "local_mail" mbox virtual 



Thanks.

Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-13 Thread Reio Remma

On 14.04.2022 08:20, Beau Ford wrote:



On Mon, 11 Apr 2022, Reio Remma wrote:

Am I misremembering or is that a possibility - to implement the '@' 
catchall directly inside smtpd.conf without reference to lookup 
tables or virtusers (or aliases) ? 


There's this format for inline tables:

table "barbaz" { foo = bar, baz = qux }



OK, I added this line to my (working) smtpd.conf:


table catchall { "@" = username }


... so there is the static table ... and "username" is a real, actual 
UNIX user in the passwd file.  Not a virtual user.



Then I added this line:


accept for any virtual  deliver to mbox


... and that line bombs out my configuration ... here is my entire 
configuration *including* these two additional lines.  This config 
works great if I remove the two new lines:


How exactly? What's the error?

https://man.openbsd.org/smtpd.conf

The "accept" is old syntax and doesn't work anymore since version... I 
can't remember. :)


So you'll want an action that delivers to mbox and an accompanying match 
rule.


Good luck
Reio





table aliases file:/usr/local/etc/mail/aliases
table catchall { "@" = username }

filter check_dyndns phase connect match rdns regex { '.*\.dyn\..*', 
'.*\.dsl\..*' } \

    disconnect "550 no residential connections"

filter check_rdns phase connect match !rdns \
    disconnect "550 no rDNS"

filter check_fcrdns phase connect match !fcrdns \
    disconnect "550 no FCrDNS"

listen on 22.44.55.135 port 10028 tag DKIM
listen on 22.44.55.135 filter \
    { check_dyndns, check_rdns, check_fcrdns }
    listen on 22.44.55.135 port submission

    action "local_mail" mbox alias 
    action "relay_dkim" relay host smtp+notls://22.44.55.135:10027
    action "outbound" relay helo mail.domain.com

    accept for any virtual  deliver to mbox

    match tag DKIM for any action "outbound"
    match from any for domain "domain.com" action "local_mail"
    match from any auth for any action "outbound"
    match for local action "local_mail"
    match for any action "relay_dkim"



My goal is to add exactly one catchall rule and keep my config simple 
inside smtpd.conf without dealing with virtual users and 
virtusertable, etc.



Thanks.






Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-13 Thread Beau Ford




On Mon, 11 Apr 2022, Reio Remma wrote:

Am I misremembering or is that a possibility - to implement the '@' 
catchall directly inside smtpd.conf without reference to lookup tables or 
virtusers (or aliases) ? 


There's this format for inline tables:

table "barbaz" { foo = bar, baz = qux }



OK, I added this line to my (working) smtpd.conf:


table catchall { "@" = username }


... so there is the static table ... and "username" is a real, actual UNIX 
user in the passwd file.  Not a virtual user.



Then I added this line:


accept for any virtual  deliver to mbox


... and that line bombs out my configuration ... here is my entire 
configuration *including* these two additional lines.  This config works 
great if I remove the two new lines:




table aliases file:/usr/local/etc/mail/aliases
table catchall { "@" = username }

filter check_dyndns phase connect match rdns regex { '.*\.dyn\..*', 
'.*\.dsl\..*' } \

disconnect "550 no residential connections"

filter check_rdns phase connect match !rdns \
disconnect "550 no rDNS"

filter check_fcrdns phase connect match !fcrdns \
disconnect "550 no FCrDNS"

listen on 22.44.55.135 port 10028 tag DKIM
listen on 22.44.55.135 filter \
{ check_dyndns, check_rdns, check_fcrdns }
listen on 22.44.55.135 port submission

action "local_mail" mbox alias 
action "relay_dkim" relay host smtp+notls://22.44.55.135:10027
action "outbound" relay helo mail.domain.com

accept for any virtual  deliver to mbox

match tag DKIM for any action "outbound"
match from any for domain "domain.com" action "local_mail"
match from any auth for any action "outbound"
match for local action "local_mail"
match for any action "relay_dkim"



My goal is to add exactly one catchall rule and keep my config simple 
inside smtpd.conf without dealing with virtual users and virtusertable, 
etc.



Thanks.



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-11 Thread Stefan Bagdohn
Here is what I do, but maybe slightly different purpose: Listen on internal 
network, accept every mail and rewrite the recipient to LOCALUSERNAME (match 
and action bbb).
The LOCALUSERNAME has a .forward file with the desired MYUSER@MYDOMAIN address, 
which is then processed by match and action aaa.

Not the most elegant solution, but gets the job done.


listen on IF0
listen on IF1
listen on IF2

table authinfo db:/etc/mail/authinfo.db

action aaa relay host smtp+tls://USERNAME@RELAYHOST auth 
action bbb mbox virtual { "@" => LOCALUSERNAME }

match from any for domain MYDOMAIN rcpt-to MYUSER@MYDOMAIN action aaa
match from any for any action bbb


br,
 Stefan


> On 11. Apr 2022, at 17:05, Beau Ford  wrote:
> 
> 
> Josey,
> 
> On Mon, 11 Apr 2022, Josey Smith wrote:
> 
>> Might not be what you want, but this two part guide includes a simple
>> catchall inbox in part two:
>> https://prefetch.eu/blog/2020/email-server/ and
>> https://prefetch.eu/blog/2020/email-server-extras/
> 
> 
> Thanks - I will look at these.
> 
> 
>> It also does use a @ in the aliases file. Does this only work with
>> virtual users?
> 
> 
> I feel like I saw an example once where the '@' catchall address was 
> implemented neither in aliases nor in virtusers - there was actually a 2-3 
> line configuration *directly inside* smtpd.conf that implemented the '@' 
> catchall.
> 
> Am I misremembering or is that a possibility - to implement the '@' catchall 
> directly inside smtpd.conf without reference to lookup tables or virtusers 
> (or aliases) ?
> 
> 
> Thanks.
> 




Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-11 Thread edgar
Sent via the Samsung Galaxy A10e, an AT&T 4G LTE smartphone
 Original message From: Beau Ford  Date: 4/11/22  
10:06 AM  (GMT-06:00) To: misc@opensmtpd.org Subject: Re: Why isn't there a 
simple way to add a catchall alias to OpenSMTP
  ? Josey,On Mon, 11 Apr 2022, Josey Smith wrote:> Might not be what you want, 
but this two part guide includes a simple> catchall inbox in part two:> 
https://prefetch.eu/blog/2020/email-server/ and> 
https://prefetch.eu/blog/2020/email-server-extras/Thanks - I will look at 
these.> It also does use a @ in the aliases file. Does this only work with> 
virtual users?I feel like I saw an example once where the '@' catchall address 
was implemented neither in aliases nor in virtusers - there was actually a 2-3 
line configuration *directly inside* smtpd.conf that implemented the '@' 
catchall.Am I misremembering or is that a possibility - to implement the '@' 
catchall directly inside smtpd.conf without reference to lookup tables or 
virtusers (or aliases) ?Thanks.You can declare tables directly in 
smtpd.conf.Edgar

Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-11 Thread Reio Remma

On 11.04.2022 18:05, Beau Ford wrote:
I feel like I saw an example once where the '@' catchall address was 
implemented neither in aliases nor in virtusers - there was actually a 
2-3 line configuration *directly inside* smtpd.conf that implemented 
the '@' catchall.


Am I misremembering or is that a possibility - to implement the '@' 
catchall directly inside smtpd.conf without reference to lookup tables 
or virtusers (or aliases) ? 


There's this format for inline tables:

table "barbaz" { foo = bar, baz = qux }

https://github.com/poolpOrg/OpenSMTPD-book/blob/master/src/chapters/1070_Understanding_tables.md

Good luck!
Reio



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-11 Thread Beau Ford



Josey,

On Mon, 11 Apr 2022, Josey Smith wrote:


Might not be what you want, but this two part guide includes a simple
catchall inbox in part two:
https://prefetch.eu/blog/2020/email-server/ and
https://prefetch.eu/blog/2020/email-server-extras/



Thanks - I will look at these.



It also does use a @ in the aliases file. Does this only work with
virtual users?



I feel like I saw an example once where the '@' catchall address was 
implemented neither in aliases nor in virtusers - there was actually a 2-3 
line configuration *directly inside* smtpd.conf that implemented the '@' 
catchall.


Am I misremembering or is that a possibility - to implement the '@' 
catchall directly inside smtpd.conf without reference to lookup tables or 
virtusers (or aliases) ?



Thanks.



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-11 Thread Reio Remma

On 11.04.2022 10:53, Josey Smith wrote:

Might not be what you want, but this two part guide includes a simple
catchall inbox in part two:
https://prefetch.eu/blog/2020/email-server/ and
https://prefetch.eu/blog/2020/email-server-extras/

It also does use a @ in the aliases file. Does this only work with
virtual users?


Yes.

https://man.openbsd.org/table.5

Good luck
Reio



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-11 Thread Josey Smith
Might not be what you want, but this two part guide includes a simple
catchall inbox in part two:
https://prefetch.eu/blog/2020/email-server/ and
https://prefetch.eu/blog/2020/email-server-extras/

It also does use a @ in the aliases file. Does this only work with
virtual users?

Josey


On 4/11/22, Beau Ford  wrote:
>
>
> Thomas,
>
>
> On Mon, 11 Apr 2022, Thomas Bohl wrote:
>
>> Instead of being cranky you should have posted your "very simple, very
>> readable smtpd.conf file".
>
>
> I'm not sure that is on-topic since my config file has no virtusertable,
> no reference to virtuals, etc.
>
> So you'd be rewriting a new config for me which seems like a lot to ask.
>
>
>>> This is what a catchall email address looks like and this is a very
>>> simple
>>> and reasonable to expect this to function.
>>
>> An alias file has never accepted an @. It is therefore not at all
>> reasonable
>> to expect it to function. IIRC even with Postfix you will need a virtual
>> map.
>
>
> The aliases file (and functionality) is very simple and straightforward.
>
> I am not sure what to do with my aliases if I establish a virtusertable
> ... do I run them in parallel ?
>
> Is virtuser functionality a superset of alias functionality ?
>
> I hear you (and others) saying that the aliases file has never allowed
> wildcards like this but ... it's not obvious why it wouldn't.  In fact, it
> seems perfectly natural to allow wildcards in it.
>
> Or, to put it another way:
>
> I have a perfectly functional config with no virtual users and no
> virtusertable ... seems like a lot of monkeying around just to add a
> single catch-all rule and never use these structures for anything else ...
>
>
> Thanks.
>
>



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-10 Thread Beau Ford




Thomas,


On Mon, 11 Apr 2022, Thomas Bohl wrote:

Instead of being cranky you should have posted your "very simple, very 
readable smtpd.conf file".



I'm not sure that is on-topic since my config file has no virtusertable, 
no reference to virtuals, etc.


So you'd be rewriting a new config for me which seems like a lot to ask.


This is what a catchall email address looks like and this is a very simple 
and reasonable to expect this to function.


An alias file has never accepted an @. It is therefore not at all reasonable 
to expect it to function. IIRC even with Postfix you will need a virtual map.



The aliases file (and functionality) is very simple and straightforward.

I am not sure what to do with my aliases if I establish a virtusertable 
... do I run them in parallel ?


Is virtuser functionality a superset of alias functionality ?

I hear you (and others) saying that the aliases file has never allowed 
wildcards like this but ... it's not obvious why it wouldn't.  In fact, it 
seems perfectly natural to allow wildcards in it.


Or, to put it another way:

I have a perfectly functional config with no virtual users and no 
virtusertable ... seems like a lot of monkeying around just to add a 
single catch-all rule and never use these structures for anything else ...



Thanks.



Re: Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-10 Thread Thomas Bohl
Instead of being cranky you should have posted your "very simple, very 
readable smtpd.conf file".


This is what a catchall email address looks like and this is a very 
simple and reasonable to expect this to function.


An alias file has never accepted an @. It is therefore not at all 
reasonable to expect it to function. IIRC even with Postfix you will 
need a virtual map.


Also, FWIW, I am on attempt number four of cramming virtusers into my 
setup that doesn't need it ... and failing.  My five minute task of 
adding a catchall email is in hour number four and it still doesn't work.


-->  Why ?  <--


Because you didn't exchanged one keyword for another? We will never know.



Why isn't there a simple way to add a catchall alias to OpenSMTP ?

2022-04-10 Thread Beau Ford



I thought this would be very simple ... I would add a line like this to my 
aliases file:



@   username


... and all email addressed to a nonexistent username would, instead, be 
received by "username".


This is what a catchall email address looks like and this is a very 
simple and reasonable to expect this to function.


Smart people reading this already know that the '@' alias is not allowed 
in the opensmtpd aliases file and that what I have just described WILL NOT 
WORK.


But why ?

What is the danger here ?  How does this break things ?  What terrible 
evils will I release upon mankind if I were (gasp!) allowed to specify an 
'@' in my aliases file and just go about my business ?


As it stands, my very simple, very readable smtpd.conf file which does not 
use a virtusertable and does not reference "virtual" anywhere now needs 
all kinds of extra complexity (double the number of lookup tables, etc.) 
just to add this one, single catch-all.


Also, FWIW, I am on attempt number four of cramming virtusers into my 
setup that doesn't need it ... and failing.  My five minute task of adding 
a catchall email is in hour number four and it still doesn't work.


-->  Why ?  <--