--- qmail-remote.c 2007-06-01 04:13:53.000000000 -0500 +++ qmail-remote.c 2007-06-01 21:42:36.000000000 -0500 @@ -564,7 +564,10 @@ if (!smtps) #endif - if (smtpcode() != 220) quit("ZConnected to "," but greeting failed"); + code = smtpcode(); + if (code >= 500 && code < 600) return; /* try next MX per RFC-2821 */ + if (code >= 400 && code < 500) return; /* try next MX per RFC-2821 */ + if (code != 220) quit("ZConnected to "," but greeting failed"); #ifdef EHLO # ifdef TLS @@ -591,7 +594,11 @@ substdio_put(&smtpto,helohost.s,helohost.len); substdio_puts(&smtpto,"\r\n"); substdio_flush(&smtpto); - if (smtpcode() != 250) quit("ZConnected to "," but my name was rejected"); + + code = smtpcode(); + if (code >= 500 && code < 600) return; /* try next MX per RFC-2821 */ + if (code >= 400 && code < 500) return; /* try next MX per RFC-2821 */ + if (code != 250) quit("ZConnected to "," but my name was rejected"); #ifdef EHLO } @@ -638,8 +645,8 @@ mail_without_auth(); } code = smtpcode(); - if (code >= 500) quit("DConnected to "," but sender was rejected"); - if (code >= 400) quit("ZConnected to "," but sender was rejected"); + if (code >= 500 && code < 600) return; /* try next MX per RFC-2821 */ + if (code >= 400 && code < 500) return; /* try next MX per RFC-2821 */ flagbother = 0; for (i = 0;i < reciplist.len;++i) { @@ -668,7 +675,7 @@ flagbother = 1; } } - if (!flagbother) quit("DGiving up on ",""); + if (!flagbother) return; /* try next MX per RFC-2821 */ substdio_putsflush(&smtpto,"DATA\r\n"); code = smtpcode(); @@ -843,7 +850,7 @@ #ifdef TLS partner_fqdn = ip.ix[i].fqdn; #endif - smtp(); /* does not return */ + smtp(); /* Returns on 400-599 error so next MX will be checked */ } tcpto_err(&ip.ix[i].ip,errno == error_timeout); close(smtpfd);