This patch is Copyright (C) 2002 - 2003 by Matthias Andree. License below. (this is the 2nd edition of this patch and the 4th edition of the introductory text) This patch changes qmail-remote to skip over MX servers that greet with codes 400 to 499 and to bounce mail when any MX server that qmail tries greets with a code 500 to 599. If you want qmail-remote to skip over hosts greeting with 5XX-codes and try the next MX for real RFC-2821 compliance (Sendmail and Postfix do that), change the if (code >= 500 && code < 600) quit("DConnected to "," but greeting failed"); to if (code >= 500 && code < 600) return; License: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- qmail-remote.c.orig Wed May 22 12:41:20 2002 +++ qmail-remote.c Wed May 22 12:52:13 2002 @@ -222,7 +222,10 @@ int flagbother; int i; - if (smtpcode() != 220) quit("ZConnected to "," but greeting failed"); + code = smtpcode(); + if (code >= 500 && code < 600) quit("DConnected to "," but greeting failed"); + if (code >= 400 && code < 500) return; /* try next MX, see RFC-2821 */ + if (code != 220) quit("ZConnected to "," but greeting failed"); substdio_puts(&smtpto,"HELO "); substdio_put(&smtpto,helohost.s,helohost.len); @@ -417,7 +420,7 @@ if (timeoutconn(smtpfd,&ip.ix[i].ip,(unsigned int) port,timeoutconnect) == 0) { tcpto_err(&ip.ix[i].ip,0); partner = ip.ix[i].ip; - smtp(); /* does not return */ + smtp(); /* only returns when the next MX is to be tried */ } tcpto_err(&ip.ix[i].ip,errno == error_timeout); close(smtpfd);