diff -ruN qmail-1.03.orig/qmail-remote.c qmail-1.03/qmail-remote.c --- qmail-1.03.orig/qmail-remote.c 2009-12-19 00:16:19.000000000 +0200 +++ qmail-1.03/qmail-remote.c 2009-12-19 00:16:46.000000000 +0200 @@ -553,15 +553,23 @@ substdio_flush(&smtpto); code = smtpcode(); if (code >= 500) { - out("h"); outhost(); out(" does not like recipient.\n"); + /* added by Endersys R&D Team */ + out("h "); outhost(); out(" does not like recipient.\n"); outsmtptext(); zero(); } else if (code >= 400) { - out("s"); outhost(); out(" does not like recipient.\n"); + /* added by Endersys R&D Team */ + out("s "); outhost(); out(" does not like recipient.\n"); outsmtptext(); zero(); } else { - out("r"); zero(); + /* + * James Raftery + * Log _real_ envelope recipient, post canonicalisation. + * and modified by Endersys R&D Team + */ + + out("r "); zero(); flagbother = 1; } } diff -ruN qmail-1.03.orig/qmail-smtpd.c qmail-1.03/qmail-smtpd.c --- qmail-1.03.orig/qmail-smtpd.c 2009-12-19 00:16:19.000000000 +0200 +++ qmail-1.03/qmail-smtpd.c 2009-12-19 00:16:39.000000000 +0200 @@ -1,3 +1,4 @@ +#include #include "sig.h" #ifndef TLS #include "readwrite.h" @@ -956,6 +957,7 @@ #endif void smtp_rcpt(arg) char *arg; { + struct stat st; rcptcounter++; if (!seenmail) { err_wantmail(); return; } if (checkrcptcount() == 1) { err_syntax(); return; } @@ -1071,6 +1073,23 @@ return; } + +/* This small patch compare mail from value and smtp auth username. +* if they are not identical, the mail will not be relayed! +* This control will be ignored, if the remote IP is defined in tcp.smtp.cdb +* create/delete control/checksenderauth file to enable/disable this feature +* - Developed by Endersys Ltd R&D Team - http://www.endersys.com +*/ + if ((stat("control/checksenderauth",&st) == 0) && (remoteinfo)) { + + /* remoteinfo:username issued during the smtp auth state + * mailfrom.s: From value issued at mail from: state */ + if (str_diff(remoteinfo, mailfrom.s)) { + out("535 Mail From address and SMTP-AUTH username does not match (#5.7.1)\r\n"); + return; + } + } + if (!stralloc_cats(&rcptto,"T")) die_nomem(); if (!stralloc_cats(&rcptto,addr.s)) die_nomem(); if (!stralloc_0(&rcptto)) die_nomem();