diff -ur postfix-2.0.16/src/global/mail_params.h postfix-2.0.16+/src/global/mail_params.h
--- postfix-2.0.16/src/global/mail_params.h	2003-03-04 07:07:03.000000000 +0900
+++ postfix-2.0.16+/src/global/mail_params.h	2004-01-12 23:39:19.000000000 +0900
@@ -828,6 +828,14 @@
 #define DEF_SMTPD_NOOP_CMDS	""
 extern char *var_smtpd_noop_cmds;
 
+#define VAR_SMTPD_RECEIVED_HEADER_FORMAT	"smtpd_received_header_format"
+#define DEF_SMTPD_RECEIVED_HEADER_FORMAT	"Received: from $helo_name ($name [$addr])$lf${tab}by $myhostname ($mail_name) with $protocol$lf${tab}id $queue_id; $time"
+extern char *var_smtpd_received_header_format;
+
+#define VAR_SMTPD_RECEIVED_HEADER_FORMAT_ONE	"smtpd_received_header_format_one"
+#define DEF_SMTPD_RECEIVED_HEADER_FORMAT_ONE	"Received: from $helo_name ($name [$addr])$lf${tab}by $myhostname ($mail_name) with $protocol id $queue_id$lf${tab}for <$recipient>; $time"
+extern char *var_smtpd_received_header_format_one;
+
  /*
   * SASL authentication support, SMTP server side.
   */
diff -ur postfix-2.0.16/src/smtpd/smtpd.c postfix-2.0.16+/src/smtpd/smtpd.c
--- postfix-2.0.16/src/smtpd/smtpd.c	2003-09-11 08:42:19.000000000 +0900
+++ postfix-2.0.16+/src/smtpd/smtpd.c	2004-01-12 23:46:22.000000000 +0900
@@ -369,6 +369,7 @@
 #include "smtpd_chat.h"
 #include "smtpd_sasl_proto.h"
 #include "smtpd_sasl_glue.h"
+#include "mac_parse.h"
 
  /*
   * Tunable parameters. Make sure that there is some bound on the length of
@@ -438,6 +439,8 @@
 int     var_relay_rcpt_code;
 char   *var_verp_clients;
 int     var_show_unk_rcpt_table;
+char	*var_smtpd_received_header_format;
+char	*var_smtpd_received_header_format_one;
 
  /*
   * Silly little macros.
@@ -989,6 +992,53 @@
     state->rcpt_count = 0;
 }
 
+typedef struct {
+    SMTPD_STATE *state;
+    VSTRING *received;
+} SMTPD_RCVD_HEADER_PARSE_ARG;
+
+static int parse_callback(int type, VSTRING *buf, char *context)
+{
+    SMTPD_RCVD_HEADER_PARSE_ARG *arg = (SMTPD_RCVD_HEADER_PARSE_ARG *)context;
+    char *s = STR(buf);
+    if (type == MAC_PARSE_LITERAL)
+	vstring_strcat(arg->received, s);
+    else if (type == MAC_PARSE_VARNAME) {
+	SMTPD_STATE *state = arg->state;
+	if (strcmp(s, "tab") == 0)
+	    vstring_strcat(arg->received, "\t");
+	else if (strcmp(s, "lf") == 0)
+	    vstring_strcat(arg->received, "\n");	    
+	else if (strcmp(s, "crlf") == 0)
+	    vstring_strcat(arg->received, "\r\n");
+	else if (strcmp(s, "helo_name") == 0)
+	    vstring_strcat(arg->received, state->helo_name ? state->helo_name : state->name);
+	else if (strcmp(s, "name") == 0)
+	    vstring_strcat(arg->received, state->name);
+	else if (strcmp(s, "addr") == 0)
+	    vstring_strcat(arg->received, state->addr);
+	else if (strcmp(s, "myhostname") == 0)
+	    vstring_strcat(arg->received, var_myhostname);
+	else if (strcmp(s, "mail_name") == 0)
+	    vstring_strcat(arg->received, var_mail_name);
+	else if (strcmp(s, "protocol") == 0)
+	    vstring_strcat(arg->received, state->protocol);
+	else if (strcmp(s, "queue_id") == 0)
+	    vstring_strcat(arg->received, state->queue_id);
+	else if (strcmp(s, "time") == 0)
+	    vstring_strcat(arg->received, mail_date(state->time));
+	else if (strcmp(s, "sender") == 0) {
+	    quote_822_local(state->buffer, state->sender);
+	    vstring_strcat(arg->received, STR(state->buffer));
+	} else if (strcmp(s, "recipient") == 0) {
+	    quote_822_local(state->buffer, state->recipient);
+	    vstring_strcat(arg->received, STR(state->buffer));
+	} else
+	    msg_warn("smtpd_received_header_format*: %s: unknown parameter", s);
+    }
+    return 0;
+}
+
 /* data_cmd - process DATA command */
 
 static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
@@ -1034,30 +1084,27 @@
     if (*var_always_bcc)
 	rec_fputs(state->cleanup, REC_TYPE_RCPT, var_always_bcc);
     rec_fputs(state->cleanup, REC_TYPE_MESG, "");
-    rec_fprintf(state->cleanup, REC_TYPE_NORM,
-		"Received: from %s (%s [%s])",
-		state->helo_name ? state->helo_name : state->name,
-		state->name, state->addr);
-    if (state->rcpt_count == 1 && state->recipient) {
-	rec_fprintf(state->cleanup, REC_TYPE_NORM,
-		    "\tby %s (%s) with %s id %s",
-		    var_myhostname, var_mail_name,
-		    state->protocol, state->queue_id);
-	quote_822_local(state->buffer, state->recipient);
-	rec_fprintf(state->cleanup, REC_TYPE_NORM,
-	      "\tfor <%s>; %s", STR(state->buffer), mail_date(state->time));
+
+    if (state->rcpt_count == 1 && state->recipient && var_smtpd_received_header_format_one) {
+	SMTPD_RCVD_HEADER_PARSE_ARG arg;
+	arg.state = state;
+	arg.received = vstring_alloc(128);
+	vstring_strcpy(arg.received, "");
+	mac_parse(var_smtpd_received_header_format_one, parse_callback, (char *)&arg);
+	rec_fputs(state->cleanup, REC_TYPE_NORM, STR(arg.received));
+	vstring_free(arg.received);
     } else {
-	rec_fprintf(state->cleanup, REC_TYPE_NORM,
-		    "\tby %s (%s) with %s",
-		    var_myhostname, var_mail_name, state->protocol);
-	rec_fprintf(state->cleanup, REC_TYPE_NORM,
-		    "\tid %s; %s", state->queue_id, mail_date(state->time));
-    }
-#ifdef RECEIVED_ENVELOPE_FROM
-    quote_822_local(state->buffer, state->sender);
-    rec_fprintf(state->cleanup, REC_TYPE_NORM,
-		"\t(envelope-from %s)", STR(state->buffer));
-#endif
+	if (var_smtpd_received_header_format) {
+	    SMTPD_RCVD_HEADER_PARSE_ARG arg;
+	    arg.state = state;
+	    arg.received = vstring_alloc(128);
+	    vstring_strcpy(arg.received, "");
+	    mac_parse(var_smtpd_received_header_format, parse_callback, (char *)&arg);
+	    rec_fputs(state->cleanup, REC_TYPE_NORM, STR(arg.received));
+	    vstring_free(arg.received);
+	}
+    }
+
     smtpd_chat_reply(state, "354 End data with <CR><LF>.<CR><LF>");
 
     /*
@@ -1637,6 +1684,13 @@
 	msg_warn("%s is true, but SASL support is not compiled in",
 		 VAR_SMTPD_SASL_ENABLE);
 #endif
+
+    var_smtpd_received_header_format = mail_conf_lookup(VAR_SMTPD_RECEIVED_HEADER_FORMAT);
+    if (var_smtpd_received_header_format == NULL)
+	var_smtpd_received_header_format = DEF_SMTPD_RECEIVED_HEADER_FORMAT;
+    var_smtpd_received_header_format_one = mail_conf_lookup(VAR_SMTPD_RECEIVED_HEADER_FORMAT_ONE);
+    if (var_smtpd_received_header_format_one == NULL)
+	var_smtpd_received_header_format_one = DEF_SMTPD_RECEIVED_HEADER_FORMAT_ONE;
 }
 
 /* main - the main program */
