Re: Change "524 5.2.4 Mailing list expansion problem" to "550 Invalid recipient"?
On Tue, 14 May 2024 11:41:54 +0100, Jesper Wallin wrote: > > ps, while writing this mail, satanist on IRC suggested the workaround > of adding 'rcpt-to ', which might invalidate my > suggestion/patch... Still, I find the mailing list expansion error more > confusing than helpful. I use rcpt-to virtual in my mail server and it replies to spammer with invlaid emails like this: May 14 10:16:58 mx2 smtpd[5018]: 112db6ee6676ecb6 smtp failed-command command="RCPT TO:" result="524 5.2.4 Mailing list expansion problem: " From my point of view your patch is the right move. -- wbr, Kirill
Change "524 5.2.4 Mailing list expansion problem" to "550 Invalid recipient"?
Hi all,
As discussed on IRC with Gilles, when using virtual table expansions
or a .forward file and the lookup fail, smtpd will respond with:
"524 5.2.4 Mailing list expansion problem", which I find vague and
confusing.
The reason for this was to make smtpd mimic the behaviour of sendmail
and to differentiate between an invalid recipient and a valid recipient
that has a configuration error, such as a broken .forward.
I can see the reasoning behind it, yet I find it very vague and it also
somewhat "leaks" details how your server is configured.
I would prefer an error like "550 Invalid recipient", since it's much
more accurate for the user sending the mail. Also it gives a much more
unified response when the recipient address is incorrect.
Regards,
Jesper
ps, while writing this mail, satanist on IRC suggested the workaround
of adding 'rcpt-to ', which might invalidate my
suggestion/patch... Still, I find the mailing list expansion error more
confusing than helpful.
Index: lka_session.c
===
RCS file: /cvs/src/usr.sbin/smtpd/lka_session.c,v
retrieving revision 1.100
diff -u -p -r1.100 lka_session.c
--- lka_session.c 2 Feb 2024 23:33:42 - 1.100
+++ lka_session.c 13 May 2024 21:12:22 -
@@ -163,9 +163,9 @@ lka_session_forward_reply(struct forward
}
if (lks->error == LKA_TEMPFAIL && lks->errormsg == NULL)
- lks->errormsg = "424 4.2.4 Mailing list expansion problem";
+ lks->errormsg = "450 Invalid recipient";
if (lks->error == LKA_PERMFAIL && lks->errormsg == NULL)
- lks->errormsg = "524 5.2.4 Mailing list expansion problem";
+ lks->errormsg = "550 Invalid recipient";
lka_resume(lks);
}
@@ -194,7 +194,7 @@ lka_resume(struct lka_session *lks)
log_trace(TRACE_EXPAND, "expand: lka_done: expanded to empty "
"delivery list");
lks->error = LKA_PERMFAIL;
- lks->errormsg = "524 5.2.4 Mailing list expansion problem";
+ lks->errormsg = "550 Invalid recipient";
}
error:
if (lks->error) {
@@ -255,7 +255,7 @@ lka_expand(struct lka_session *lks, stru
if (xn->depth >= EXPAND_DEPTH) {
log_trace(TRACE_EXPAND, "expand: lka_expand: node too deep.");
lks->error = LKA_PERMFAIL;
- lks->errormsg = "524 5.2.4 Mailing list expansion problem";
+ lks->errormsg = "550 Invalid recipient";
return;
}
@@ -331,9 +331,9 @@ lka_expand(struct lka_session *lks, stru
"no aliases for virtual");
}
if (lks->error == LKA_TEMPFAIL && lks->errormsg == NULL)
- lks->errormsg = "424 4.2.4 Mailing list
expansion problem";
+ lks->errormsg = "450 Invalid recipient";
if (lks->error == LKA_PERMFAIL && lks->errormsg == NULL)
- lks->errormsg = "524 5.2.4 Mailing list
expansion problem";
+ lks->errormsg = "550 Invalid recipient";
}
else {
lks->expand.rule = rule;
Re: Mailing list expansion problem.
On 02.11.2019 0:41, Reio Remma wrote: On 31.10.2019 10:06, [email protected] wrote: October 26, 2019 1:23 PM, "Reio Remma" wrote: On 26/10/2019 14:18, Reio Remma wrote: On the subject of catch all aliases, I tried adding one to my setup > with odd results. My usual setup with virtual users: action deliver_lmtp lmtp "/var/run/dovecot/lmtp" rcpt-to virtual > userbase match from any for domain rcpt-to action > deliver_lmtp To get catch all working, I had to remove rcpt-to from > the match: match from any for domain action deliver_lmtp Otherwise the response was: 550 Invalid recipient: One I removed the actual catch all alias and sent mail to a > non-existent account, the usual: 550 Invalid recipient: turned into: 524 5.2.4 Mailing list expansion problem: Any ideas how I could use a catch all alias _and_ get a proper 550 > Invalid recipient if I don't? This is all with the current (v6.6) portable from a week ago or so. This error occurs when aliases expansion encounters an error during its processing, there's not enough info here to understand what happened in the expansion loop: - it is likely a table content issue either in virtuals or in userinfo table or both - using `smtpd -dv -T expand` will help you understand what went wrong during expansion Gilles A couple of hours reading code and I'm fairly certain catchall aliases don't work at all with database backends. Mailaddr lookups from static tables use mailaddr_match to compare address parts with catchall aliases, but table-mysql for example doesn't do any extra work. expand: 0x23b6628: expand_insert() called for address:[email protected][parent=(nil), rule=(nil)] expand: 0x23b6628: inserted node 0x23b8320 expand: lka_expand: address: [email protected] [depth=0] lookup: match "209.85.167.41" as NETADDR in table static: -> true lookup: match "domain.com" as DOMAIN in table static: -> true lookup: match "[email protected]" as MAILADDR in table proc:blacklist -> false lookup: match "209.85.167.41" as NETADDR in table static: -> true lookup: match "domain.com" as DOMAIN in table proc:domains -> true lookup: match "[email protected]" as MAILADDR in table proc:recipients -> false lookup: match "209.85.167.41" as NETADDR in table static: -> false lookup: match "209.85.167.41" as NETADDR in table static: -> true lookup: match "domain.com" as DOMAIN in table static: -> true lookup: match "209.85.167.41" as NETADDR in table static: -> false lookup: match "209.85.167.41" as NETADDR in table static:sources -> false no rule matched The only query I see in the query log is trying to match the full recipient address: SELECT mailaddr FROM virtuals WHERE mailaddr = '[email protected]' This works: match from any for domain rcpt-to {'@domain.com', ... } action deliver This doesn't: match from any for domain rcpt-to action deliver
Re: Mailing list expansion problem.
On 31.10.2019 10:06, [email protected] wrote: October 26, 2019 1:23 PM, "Reio Remma" wrote: On 26/10/2019 14:18, Reio Remma wrote: On the subject of catch all aliases, I tried adding one to my setup > with odd results. My usual setup with virtual users: action deliver_lmtp lmtp "/var/run/dovecot/lmtp" rcpt-to virtual > userbase match from any for domain rcpt-to action > deliver_lmtp To get catch all working, I had to remove rcpt-to from > the match: match from any for domain action deliver_lmtp Otherwise the response was: 550 Invalid recipient: One I removed the actual catch all alias and sent mail to a > non-existent account, the usual: 550 Invalid recipient: turned into: 524 5.2.4 Mailing list expansion problem: Any ideas how I could use a catch all alias _and_ get a proper 550 > Invalid recipient if I don't? This is all with the current (v6.6) portable from a week ago or so. This error occurs when aliases expansion encounters an error during its processing, there's not enough info here to understand what happened in the expansion loop: - it is likely a table content issue either in virtuals or in userinfo table or both - using `smtpd -dv -T expand` will help you understand what went wrong during expansion Gilles A couple of hours reading code and I'm fairly certain catchall aliases don't work at all with database backends. Mailaddr lookups from static tables use mailaddr_match to compare address parts with catchall aliases, but table-mysql for example doesn't do any extra work. Reio
Re: Mailing list expansion problem.
October 26, 2019 1:23 PM, "Reio Remma" wrote: > On 26/10/2019 14:18, Reio Remma wrote: > >> On the subject of catch all aliases, I tried adding one to my setup > with >> odd results. >> >> My usual setup with virtual users: >> >> action deliver_lmtp lmtp "/var/run/dovecot/lmtp" rcpt-to virtual > >> userbase >> >> match from any for domain rcpt-to action > >> deliver_lmtp >> >> To get catch all working, I had to remove rcpt-to from > the >> match: >> >> match from any for domain action deliver_lmtp >> >> Otherwise the response was: 550 Invalid recipient: >> >> One I removed the actual catch all alias and sent mail to a > non-existent >> account, the usual: >> >> 550 Invalid recipient: >> >> turned into: >> >> 524 5.2.4 Mailing list expansion problem: >> >> Any ideas how I could use a catch all alias _and_ get a proper 550 > Invalid >> recipient if I don't? > > This is all with the current (v6.6) portable from a week ago or so. This error occurs when aliases expansion encounters an error during its processing, there's not enough info here to understand what happened in the expansion loop: - it is likely a table content issue either in virtuals or in userinfo table or both - using `smtpd -dv -T expand` will help you understand what went wrong during expansion Gilles
Re: Mailing list expansion problem.
On 26/10/2019 14:18, Reio Remma wrote: On the subject of catch all aliases, I tried adding one to my setup with odd results. My usual setup with virtual users: action deliver_lmtp lmtp "/var/run/dovecot/lmtp" rcpt-to virtual userbase match from any for domain rcpt-to action deliver_lmtp To get catch all working, I had to remove rcpt-to from the match: match from any for domain action deliver_lmtp Otherwise the response was: 550 Invalid recipient: One I removed the actual catch all alias and sent mail to a non-existent account, the usual: 550 Invalid recipient: turned into: 524 5.2.4 Mailing list expansion problem: Any ideas how I could use a catch all alias _and_ get a proper 550 Invalid recipient if I don't? This is all with the current (v6.6) portable from a week ago or so.
Mailing list expansion problem.
On the subject of catch all aliases, I tried adding one to my setup with odd results. My usual setup with virtual users: action deliver_lmtp lmtp "/var/run/dovecot/lmtp" rcpt-to virtual userbase match from any for domain rcpt-to action deliver_lmtp To get catch all working, I had to remove rcpt-to from the match: match from any for domain action deliver_lmtp Otherwise the response was: 550 Invalid recipient: One I removed the actual catch all alias and sent mail to a non-existent account, the usual: 550 Invalid recipient: turned into: 524 5.2.4 Mailing list expansion problem: Any ideas how I could use a catch all alias _and_ get a proper 550 Invalid recipient if I don't? Thanks, Reio
