summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-06-04 04:25:41 (GMT)
committerJohn Denker <jsd@av8n.com>2012-07-14 01:39:07 (GMT)
commit8ebb34bd4f4328f7828735be480d77f884f9359a (patch)
treeea4015a366a476ad93035bf83bd7c776f6cfb3b2
parentd878633536cadc60e6d836c946673903dbac263a (diff)
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.
-rw-r--r--qmail-smtpd.c17
1 files changed, 17 insertions, 0 deletions
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;