[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mail not bounced after a 5xx error





On Mon, 14 Apr 2003 wilbert.schapendonk@nld.mci.com wrote:

> Hi,
>
> We are running Zmailer 2.99.56-pre4 #1 from CVS and are experiencing a
> problem where zmailer leaves mail in the queue when the remote server
> issues a 5xx error after the 'MAIL FROM' command and an additional 5xx
> error when zmailer continues with a 'RCPT TO' command.
>
> The session goes like this:
>
>     220 mail.exampledomain.com ESMTP Sendmail 8.12.8/8.12.6; Mon, 14 Apr 2003 11:31:54 +0200 (CEST)
>     EHLO fallback.exampledomain.com
>     250-mail.exampledomain.com Hello fallback.exampledomain.com, pleased to meet you
>     250-ENHANCEDSTATUSCODES
>     250-PIPELINING
>     250-8BITMIME
>     250-SIZE
>     250-DSN
>     250-ETRN
>     250-DELIVERBY
>     250 HELP
>     MAIL From:<junk@spammerdomain.com> BODY=8BITMIME SIZE=381
>     RCPT To:<user@exampledomain.com>
>     DATA
>     550 5.0.0 <junk@spammerdomain.com>... Go away, we don't want you here
>     503 5.0.0 Need MAIL before RCPT
>     503 5.0.0 Need MAIL command
>     RSET
>
> This mail would stay in the queue with 'stat=deferred  ->> 503 5.0.0 Need
> MAIL before RCPT' and zmailer will try to deliver it using the same
> sequence of commands until the mail expires.
>
> Is there a way to get these messages bounced after the first delivery
> attempt?
>
> Thanks,
>

Here is my patches to smtp.c for zmailer-2.99.55

This is solution for
	- "Mail not bounced after a 5xx error" problem (no Disabling pipelining required).
 	- unadequate diagnostics for 5xx errors at data command like:
		# FAILED:
		#   Original Recipient:
		#     rfc822;rom7@list.ru
		#   Control data:
		#     smtp list.ru rom7@list.ru 65534
		#   Diagnostic texts:
		# ...\
		#     <<- MAIL From:<bag@alcatraz.iptelecom.net.ua> BODY=8BITMIME SIZE=1182
		#     ->> 250 OK
		#     <<- RCPT To:<rom7@list.ru>
		#     ->> 250 Accepted
		#     <<- RSET
		#     ->> 250 Reset OK

		pathched smtp produces:

		# FAILED:
		#   Original Recipient:
		#     rfc822;test0101@list.ru
		#   Control data:
		#     smtp list.ru test0101@list.ru 65534
		#   Diagnostic texts:
		# ...\
		#     <<- MAIL From:<bag@alcatraz.iptelecom.net.ua> BODY=8BITMIME SIZE=582
		#     ->> 250 OK
		#     <<- RCPT To:<rom7@list.ru>
		#     ->> 250 Accepted
		#     <<- DATA
		#     ->> 503 Administrative prohibition ....

	- more adequate proctitle under FreeBSD 4.XXX






--- dist.zmailer/zmailer-2.99.55/transports/smtp/smtp.c	Thu Jan 25 14:32:28 2001
+++ zmailer.bag/work/zmailer-2.99.55/transports/smtp/smtp.c	Thu Apr 24 00:21:34 2003
@@ -1245,6 +1245,16 @@

 	  SS->cmdstate     = SMTPSTATE_RCPTTO; /* 1 + MAILFROM.. */

+	  for (rp = startrp; rp && rp != endrp; rp = rp->next) {
+	    /* NOTARY: address / action / status / diagnostic */
+	    if (rp->lockoffset) {
+		notaryreport(rp->addr->user, FAILED,
+			   "5.5.0 (Undetermined protocol error)",NULL);
+	      diagnostic(rp, r, 0, "%s", SS->remotemsg);
+	    }
+	  }
+
+// bag reset should be after diag...
 	  if (SS->smtpfp) {
 	    SS->rcptstates = 0;
 	    if (smtpwrite(SS, 0, "RSET", 0, NULL) == EX_OK)
@@ -1254,14 +1264,6 @@
 	      }
 	  }

-	  for (rp = startrp; rp && rp != endrp; rp = rp->next) {
-	    /* NOTARY: address / action / status / diagnostic */
-	    if (rp->lockoffset) {
-		notaryreport(rp->addr->user, FAILED,
-			   "5.5.0 (Undetermined protocol error)",NULL);
-	      diagnostic(rp, r, 0, "%s", SS->remotemsg);
-	    }
-	  }
 	  return r;
 	}
 	mail_from_failed = 0;
@@ -1487,14 +1489,6 @@
 	      close_after_data = 1;
 	      r = EX_TEMPFAIL;
 	    }
-
-	    if (SS->smtpfp) {
-	      SS->rcptstates = 0;
-	      if (smtpwrite(SS, 0, "RSET", 0, NULL) == EX_OK)
-		/* r = EX_TEMPFAIL */ ;
-
-	    }
-
 	    if (SS->verboselog)
 	      fprintf(SS->verboselog," .. timeout ? smtp_sync() rc = %d\n",r);

@@ -1511,6 +1505,14 @@
 		diagnostic(rp, r, 0, "%s", SS->remotemsg);
 	      }

+// bag reset should be after diag...
+	    if (SS->smtpfp) {
+	      SS->rcptstates = 0;
+	      if (smtpwrite(SS, 0, "RSET", 0, NULL) == EX_OK)
+		/* r = EX_TEMPFAIL */ ;
+	    }
+
+
 	    return r;
 	  }

@@ -3673,9 +3675,10 @@
 		SS->rcptstates |= RCPTSTATE_400;
 		rc = EX_TEMPFAIL;
 	      } else {
-		if (code >= 500)
+		if (code >= 500 && (SS->rcptstates & FROMSTATE_500)) {
 		  SS->rcptstates |= RCPTSTATE_500;
-		else
+		  rc = EX_UNAVAILABLE;
+		} else
 		  SS->rcptstates |= RCPTSTATE_400;
 		/* ``rc'' is correct. */
 	      }
@@ -3698,9 +3701,10 @@
 		  (STREQN(SS->pipecmds[idx],"MAIL", 4))) {
 		/* We are working on MAIL From:<...> command here */

-		if (code >= 500)
+		if (code >= 500) {
 		  SS->rcptstates |= FROMSTATE_500;
-		else if (code >= 400)
+		  SS->rcptstates |= RCPTSTATE_500;
+		} else if (code >= 400)
 		  SS->rcptstates |= FROMSTATE_400;
 		else
 		  SS->rcptstates |= FROMSTATE_OK;
@@ -3723,6 +3727,12 @@
 		if (code >= 500) {
 		  if (SS->rcptstates & (FROMSTATE_400|FROMSTATE_500)) {
 		    /* The FROM failed already, make us 'soft' */
+// bag
+		    if (SS->rcptstates & FROMSTATE_500) {
+			SS->rcptstates |= DATASTATE_500;
+		  	SS->rcptstates |= RCPTSTATE_500;
+		    } else
+// bag end
 		    SS->rcptstates |= DATASTATE_400;
 		  } else if (SS->rcptstates & RCPTSTATE_OK) {
 		    /* At least one OK result for RCPTs,
@@ -3736,6 +3746,12 @@
 		    SS->rcptstates |= DATASTATE_500;
 		  }
 		} else if (code >= 400) {
+// bag
+		  if (SS->rcptstates & FROMSTATE_500) {
+			SS->rcptstates |= DATASTATE_500;
+		  	SS->rcptstates |= RCPTSTATE_500;
+		  } else
+// bag end
 		  SS->rcptstates |= DATASTATE_400;
 		}
 	      }
@@ -3750,7 +3766,13 @@
 	      if (SS->rcptstates & (FROMSTATE_400|FROMSTATE_500)) {
 		/* MAIL FROM gave error, we won't believe OK on
 		   recipients either. */
+// bag
+		if (SS->rcptstates & FROMSTATE_500)
+			SS->rcptstates |= RCPTSTATE_500;
+		else
+// bag end
 		SS->rcptstates |= RCPTSTATE_400;
+
 		/* Actually we SHOULD NOT arrive here, but we never know,
 		   what kind of smtp-servers are out there... */
 	      } else {
@@ -4087,6 +4109,7 @@
 	SS  = va_arg(ap, SmtpState *);
 	fmt = va_arg(ap, char *);
 #endif
+	bzero(buf, sizeof(buf));
 	if (SS->smtpfp && sffileno(SS->smtpfp) >= 0)
 	  sprintf(buf, ">%.200s ", SS->remotehost);
 	else
@@ -4096,18 +4119,20 @@
 	  sprintf(buf+strlen(buf), ">>%s ", logfile);
 	strcat(buf, "# ");
 #endif
+	setproctitle("%s", buf);
 #ifdef	HAVE_VPRINTF
 	vsprintf(buf+strlen(buf), fmt, ap);
 #else	/* !HAVE_VPRINTF */
 	sprintf(buf+strlen(buf), fmt, va_arg(ap, char *));
 #endif	/* HAVE_VPRINTF */
+	setproctitle("%s", buf);
 	cmdlen = (eocmdline - cmdline);
 	if (cmdlen >= sizeof(buf))
 	  cmdlen = sizeof(buf) - 1;
 	for (fmt = buf+strlen(buf); fmt < buf + cmdlen; ++fmt)
 	  *fmt = '\0';
 	buf[cmdlen] = '\0';
-	memcpy((char*)cmdline, buf, cmdlen); /* Overwrite it! */
+/*	memcpy((char*)cmdline, buf, cmdlen); *//* Overwrite it! */
 	va_end(ap);
 }


-
To unsubscribe from this list: send the line "unsubscribe zmailer" in
the body of a message to majordomo@nic.funet.fi