Henning Brauer wrote:
> 
> Hiya,
> 
> there was a discussion on the main qmail list recently if messages with
> an empty envelope sender may contain more than one recipient. We agreed
> they may not. Charles Cazabon wrote a small patch implementing this
> restriction.
> I picked up the idea for qmail-ldap; for us it is much easier to implement as
> we already count recipients for maxrcpt and tarpitting. I don't see any
> reason to accept a bounce message with more than one recipient, so I didn't
> bother with control files, environment variables and so on; so the whole
> patch consists of two added lines:
-snip-
> I'd love to see this included in the next patch.

Could you check out this improved version?

The mail attempt should not be rejected at the data phase but already
at the time when a second rcpt-to is tried. Also it extends the bounce
detection logic a bit (from the NOSPAM patch included in qmail-ldap).

Index: qmail-smtpd.c
===================================================================
RCS file: /usr/home/cvs-qmail-ldap/CVS/qmail-ldap/qmail-smtpd.c,v
retrieving revision 1.39
retrieving revision 1.41
diff -u -r1.39 -r1.41
--- qmail-smtpd.c       2001/05/04 13:30:06     1.39
+++ qmail-smtpd.c       2001/12/14 14:48:14     1.41
@@ -139,6 +139,7 @@
 void err_rbl(arg) char *arg; { out("553 sorry, your mailserver is
listed in "); out(arg); out(", mail from your location is not accepted
here (#5.7.1)\r\n"); }
 void err_maxrcpt() { out("553 sorry, too many recipients
(#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_badbounce() { out("550 sorry, I don't accept bounce messages
with more than one recipient. Go read RFC2821. (#5.7.1)\r\n"); }
 #ifdef TLS
 void err_nogwcert() { out("553 no valid cert for gatewaying
(#5.7.1)\r\n"); }
 #endif
@@ -595,6 +596,7 @@
   logpid(3); logstring(3,"remote ehlo ="); logstring(3,arg);
logflush(3);
   logpid(3); logstring(3,"max msg size ="); logstring(3,smtpsize);
logflush(3);
 }
+
 void smtp_rset()
 {
   seenmail = 0;
@@ -856,6 +858,11 @@
     err_maxrcpt();
     logline(1,"message denied because of more 'RCPT TO' than allowed by
MAXRCPTCOUNT");
     return;
+  }
+  if ( rcptcount > 1 && (addr.s[0] || str_diff("#@[]", addr.s)) )
+  {
+    err_badbounce();
+    logline(1,"bounce message denied because it has more than one
recipient");
   }
   if (!stralloc_cats(&rcptto,"T")) die_nomem();
   if (!stralloc_cats(&rcptto,addr.s)) die_nomem();

-- 
Andre

Reply via email to