dovecot-2.0: lmtp: Add Return-Path: header. Also with only one R...
dovecot at dovecot.org
dovecot at dovecot.org
Tue May 25 18:45:29 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/61c3124bba93
changeset: 11367:61c3124bba93
user: Timo Sirainen <tss at iki.fi>
date: Tue May 25 16:45:18 2010 +0100
description:
lmtp: Add Return-Path: header. Also with only one RCPT TO, add Delivered-To: header.
diffstat:
src/lmtp/client.h | 2 +-
src/lmtp/commands.c | 33 ++++++++++++++++++++-------------
2 files changed, 21 insertions(+), 14 deletions(-)
diffs (85 lines):
diff -r 4c28061ce7a6 -r 61c3124bba93 src/lmtp/client.h
--- a/src/lmtp/client.h Tue May 25 16:31:39 2010 +0100
+++ b/src/lmtp/client.h Tue May 25 16:45:18 2010 +0100
@@ -25,7 +25,7 @@
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;
diff -r 4c28061ce7a6 -r 61c3124bba93 src/lmtp/commands.c
--- a/src/lmtp/commands.c Tue May 25 16:31:39 2010 +0100
+++ b/src/lmtp/commands.c Tue May 25 16:45:18 2010 +0100
@@ -522,8 +522,8 @@
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 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 @@
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 @@
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 @@
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 {
More information about the dovecot-cvs
mailing list