From a560c4ac596a75492e77378b2cca349c91402e2a Mon Sep 17 00:00:00 2001 From: John Denker Date: Sun, 3 Jun 2012 22:45:45 -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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qmail-smtpd.c b/qmail-smtpd.c index 8c88c4b..23f9c89 100644 --- a/qmail-smtpd.c +++ b/qmail-smtpd.c @@ -58,6 +58,7 @@ void die_control() { out("421 unable to read controls (#4.3.0)\r\n"); flush(); _ void die_ipme() { out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1); } void straynewline() { out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); _exit(1); } +void err_badbounce() { out("550 sorry, bounce messages should have a single envelope recipient (#5.7.1)\r\n"); } void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); } 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"); } @@ -258,6 +259,7 @@ int seenmail = 0; int flagbarf; /* defined if seenmail */ stralloc mailfrom = {0}; stralloc rcptto = {0}; +int recipcount; char *hostname; char **childargs; @@ -311,6 +313,7 @@ void smtp_rcpt(arg) char *arg; { if (!stralloc_cats(&rcptto,"T")) die_nomem(); if (!stralloc_cats(&rcptto,addr.s)) die_nomem(); if (!stralloc_0(&rcptto)) die_nomem(); + recipcount++; out("250 ok\r\n"); } @@ -422,6 +425,7 @@ void smtp_data(arg) char *arg; { if (!seenmail) { err_wantmail(); return; } if (!rcptto.len) { err_wantrcpt(); return; } + if (mailfrom.len == 1 && recipcount > 1) { err_badbounce(); return; } seenmail = 0; if (databytes) bytestooverflow = databytes + 1; if (qmail_open(&qqt) == -1) { err_qqt(); return; } -- cgit v1.2.3