From 8ebb34bd4f4328f7828735be480d77f884f9359a Mon Sep 17 00:00:00 2001 From: John Denker Date: Sun, 3 Jun 2012 21:25:41 -0700 Subject: Reject emails addressed to multiple recipients with a null envelope sender. A lot of your spam will be arriving with a null envelope sender. When those spam messages have multiple envelope recipients, they cannot be bounce messages. --- qmail-smtpd.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/qmail-smtpd.c b/qmail-smtpd.c index 1064008..8c88c4b 100644 --- a/qmail-smtpd.c +++ b/qmail-smtpd.c @@ -62,6 +62,7 @@ void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list void err_nogateway() { out("553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)\r\n"); } void err_unimpl(arg) char *arg; { out("502 unimplemented (#5.5.1)\r\n"); } void err_syntax() { out("555 syntax error (#5.5.4)\r\n"); } +void err_relay() { out("553 we don't relay (#5.7.1)\r\n"); } void err_wantmail() { out("503 MAIL first (#5.5.1)\r\n"); } void err_wantrcpt() { out("503 RCPT first (#5.5.1)\r\n"); } void err_noop(arg) char *arg; { out("250 ok\r\n"); } @@ -237,6 +238,21 @@ int addrallowed() return r; } +int addrrelay() +{ + int j; + j = addr.len; + while(--j >= 0) + if (addr.s[j] == '@') break; + if (j < 0) j = addr.len; + while(--j >= 0) { + if (addr.s[j] == '@') return 1; + if (addr.s[j] == '%') return 1; + if (addr.s[j] == '!') return 1; + } + return 0; +} + int seenmail = 0; int flagbarf; /* defined if seenmail */ @@ -283,6 +299,7 @@ void smtp_mail(arg) char *arg; void smtp_rcpt(arg) char *arg; { if (!seenmail) { err_wantmail(); return; } if (!addrparse(arg)) { err_syntax(); return; } + if (addrrelay()) { err_relay(); return; } if (flagbarf) { err_bmf(); return; } if (relayclient) { --addr.len; -- cgit v1.2.3