--- postfix-2.2-20040422/src/smtpd/smtpd_check.c	Mon Apr 19 21:31:20 2004
+++ postfix-2.2-20040422-sender-rewrite/src/smtpd/smtpd_check.c	Thu May 13 23:47:23 2004
@@ -1781,6 +1781,52 @@
     }
 
     /*
+     * SENDER_REWRITE
+     */
+    if (STREQUAL(value, "SENDER_REWRITE", cmd_len)) {
+#ifndef TEST
+	if (can_delegate_action(state, table, "SENDER_REWRITE", reply_class) == 0)
+	    return (SMTPD_CHECK_DUNNO);
+#endif
+	if (strchr(cmd_text, '@') == 0) {
+	    msg_warn("access map %s entry \"%s\" requires user@domain target",
+		     table, datum);
+	    return (SMTPD_CHECK_DUNNO);
+	} else {
+	    vstring_sprintf(error_text, "<%s>: %s trigger SENDER_REWITE %s",
+			    reply_name, reply_class, cmd_text);
+	    log_whatsup(state, "sender_rewrite", STR(error_text));
+#ifndef TEST
+	    UPDATE_STRING(state->sender, cmd_text);
+#endif
+	    return (SMTPD_CHECK_DUNNO);
+	}
+    }
+
+    /*
+     * RECIPIENT_REWRITE
+     */
+    if (STREQUAL(value, "RECIPIENT_REWRITE", cmd_len)) {
+#ifndef TEST
+	if (can_delegate_action(state, table, "RECIPIENT_REWRITE", reply_class) == 0)
+	    return (SMTPD_CHECK_DUNNO);
+#endif
+	if (strchr(cmd_text, '@') == 0) {
+	    msg_warn("access map %s entry \"%s\" requires user@domain target",
+		     table, datum);
+	    return (SMTPD_CHECK_DUNNO);
+	} else {
+	    vstring_sprintf(error_text, "<%s>: %s trigger RECIPIENT_REWRITE %s",
+			    reply_name, reply_class, cmd_text);
+	    log_whatsup(state, "recipient_rewrite", STR(error_text));
+#ifndef TEST
+	    UPDATE_STRING(state->recipient, cmd_text);
+#endif
+	    return (SMTPD_CHECK_DUNNO);
+	}
+    }
+
+    /*
      * REDIRECT means deliver to designated recipient. But we may still
      * change our mind, and reject/discard the message for other reasons.
      */
