summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-06-03 22:45:45 -0700
committerJohn Denker <jsd@av8n.com>2012-07-13 18:39:07 -0700
commita560c4ac596a75492e77378b2cca349c91402e2a (patch)
tree1965d92f70af384f36b2261207c6705f6e0c0319
parent425d3db4e3ad58b7ea5d185accfd16e8079613f1 (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.c4
1 files changed, 4 insertions, 0 deletions
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; }