--- qmail-1.03.orig/qmail-smtpd.c 2005-01-05 23:08:02.724271992 +0100 +++ qmail-1.03/qmail-smtpd.c 2005-01-05 23:09:00.374507824 +0100 @@ -94,6 +94,7 @@ #endif void err_unimpl() { out("502 unimplemented (#5.5.1)\r\n"); } void err_syntax() { out("555 syntax error (#5.5.4)\r\n"); } +void err_relay() { out("553 we don't relay (#5.7.1)\r\n"); } void err_wantmail() { out("503 MAIL first (#5.5.1)\r\n"); } void err_wantrcpt() { out("503 RCPT first (#5.5.1)\r\n"); } void err_noop() { out("250 ok\r\n"); } @@ -331,6 +332,20 @@ return r; } +int addrrelay() +{ + int j; + j = addr.len; + while(--j >= 0) + if (addr.s[j] == '@') break; + if (j < 0) j = addr.len; + while(--j >= 0) { + if (addr.s[j] == '@') return 1; + if (addr.s[j] == '%') return 1; + if (addr.s[j] == '!') return 1; + } + return 0; +} int seenmail = 0; int flagbarfbmf; /* defined if seenmail */ @@ -451,6 +466,7 @@ void smtp_rcpt(arg) char *arg; { if (!seenmail) { err_wantmail(); return; } if (!addrparse(arg)) { err_syntax(); return; } + if (addrrelay()) { err_relay(); return; } if (flagbarfbhelo) { strerr_warn4("qmail-smtpd: badhelo: <",helohost.s,"> at ",remoteip,0); err_bhelo();