]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: Add Return-Path: header. Also with only one RCPT TO, add Delivered-To: header.
authorTimo Sirainen <tss@iki.fi>
Tue, 25 May 2010 15:45:18 +0000 (16:45 +0100)
committerTimo Sirainen <tss@iki.fi>
Tue, 25 May 2010 15:45:18 +0000 (16:45 +0100)
--HG--
branch : HEAD

src/lmtp/client.h
src/lmtp/commands.c

index 85491203d212eb85510731a79d093fb912d4b95c..1f08c957035ae68e29d76376f9269380f0fad7ce 100644 (file)
@@ -25,7 +25,7 @@ struct client_state {
        buffer_t *mail_data;
        int mail_data_fd;
        struct ostream *mail_data_output;
-       const char *received_line;
+       const char *added_headers;
 
        struct mailbox *raw_box;
        struct mailbox_transaction_context *raw_trans;
index e882e9e7eed3ad0c8534f67b492ff85989552e0d..9878325e070941fde8eb191e11b08a236484dc28 100644 (file)
@@ -522,8 +522,8 @@ static struct istream *client_get_input(struct client *client)
        struct client_state *state = &client->state;
        struct istream *cinput, *inputs[3];
 
-       inputs[0] = i_stream_create_from_data(state->received_line,
-                                             strlen(state->received_line));
+       inputs[0] = i_stream_create_from_data(state->added_headers,
+                                             strlen(state->added_headers));
 
        if (state->mail_data_output != NULL) {
                o_stream_unref(&state->mail_data_output);
@@ -636,10 +636,21 @@ static void client_proxy_finish(bool timeout, void *context)
        }
 }
 
-static const char *client_get_received_line(struct client *client)
+static const char *client_get_added_headers(struct client *client)
 {
        string_t *str = t_str_new(200);
-       const char *host;
+       const char *host, *rcpt_to = NULL;
+
+       if (array_count(&client->state.rcpt_to) == 1) {
+               const struct mail_recipient *rcpt =
+                       array_idx(&client->state.rcpt_to, 0);
+
+               rcpt_to = rcpt->address;
+       }
+
+       str_printfa(str, "Return-Path: <%s>\r\n", client->state.mail_from);
+       if (rcpt_to != NULL)
+               str_printfa(str, "Delivered-To: <%s>\r\n", rcpt_to);
 
        str_printfa(str, "Received: from %s", client->state.lhlo);
        if ((host = net_ip2addr(&client->remote_ip)) != NULL)
@@ -648,12 +659,8 @@ static const char *client_get_received_line(struct client *client)
                    client->my_domain, client->state.session_id);
 
        str_append(str, "\r\n\t");
-       if (array_count(&client->state.rcpt_to) == 1) {
-               const struct mail_recipient *rcpt =
-                       array_idx(&client->state.rcpt_to, 0);
-
-               str_printfa(str, "for <%s>", rcpt->address);
-       }
+       if (rcpt_to != NULL)
+               str_printfa(str, "for <%s>", rcpt_to);
        str_printfa(str, "; %s\r\n", message_date_create(ioloop_time));
        return str_c(str);
 }
@@ -776,8 +783,8 @@ int cmd_data(struct client *client, const char *args ATTR_UNUSED)
                return 0;
        }
 
-       client->state.received_line =
-               p_strdup(client->state_pool, client_get_received_line(client));
+       client->state.added_headers =
+               p_strdup(client->state_pool, client_get_added_headers(client));
 
        i_assert(client->state.mail_data == NULL);
        client->state.mail_data = buffer_create_dynamic(default_pool, 1024*64);
@@ -790,7 +797,7 @@ int cmd_data(struct client *client, const char *args ATTR_UNUSED)
        if (array_count(&client->state.rcpt_to) == 0) {
                timeout_remove(&client->to_idle);
                lmtp_proxy_start(client->proxy, client->dot_input,
-                                client->state.received_line,
+                                client->state.added_headers,
                                 client_proxy_finish, client);
                i_stream_unref(&client->dot_input);
        } else {