From: Stephan Bosch Date: Fri, 13 Sep 2019 20:33:05 +0000 (+0200) Subject: lib-smtp: smtp-client - Add support for proxying MAIL command with broken path. X-Git-Tag: 2.3.9~116 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4ce99b94ad4c07b73eea034bc18e6f4e9f4cbab9;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-client - Add support for proxying MAIL command with broken path. --- diff --git a/src/lib-smtp/smtp-client-command.c b/src/lib-smtp/smtp-client-command.c index e9a4a3b6f8..87f13fba53 100644 --- a/src/lib-smtp/smtp-client-command.c +++ b/src/lib-smtp/smtp-client-command.c @@ -1117,8 +1117,15 @@ smtp_client_command_mail_submit(struct smtp_client_connection *conn, flags |= SMTP_CLIENT_COMMAND_FLAG_PIPELINE; cmd = smtp_client_command_new(conn, flags, callback, context); - smtp_client_command_printf(cmd, "MAIL FROM:<%s>", - smtp_address_encode(from)); + if (!conn->set.mail_send_broken_path || !smtp_address_is_broken(from)) { + /* Compose MAIL command with normalized path. */ + smtp_client_command_printf(cmd, "MAIL FROM:<%s>", + smtp_address_encode(from)); + } else { + /* Compose MAIL command with broken path (for proxy). */ + smtp_client_command_printf(cmd, "MAIL FROM:<%s>", + smtp_address_encode_raw(from)); + } if (params != NULL) { size_t orig_len = str_len(cmd->data); str_append_c(cmd->data, ' '); diff --git a/src/lib-smtp/smtp-client-connection.c b/src/lib-smtp/smtp-client-connection.c index d177f962e0..610cca0ef5 100644 --- a/src/lib-smtp/smtp-client-connection.c +++ b/src/lib-smtp/smtp-client-connection.c @@ -1803,6 +1803,8 @@ smtp_client_connection_do_create(struct smtp_client *client, const char *name, &set->proxy_data); conn->set.xclient_defer = set->xclient_defer; conn->set.peer_trusted = set->peer_trusted; + + conn->set.mail_send_broken_path = set->mail_send_broken_path; } diff --git a/src/lib-smtp/smtp-client-transaction.c b/src/lib-smtp/smtp-client-transaction.c index 39b9b35376..9968030b84 100644 --- a/src/lib-smtp/smtp-client-transaction.c +++ b/src/lib-smtp/smtp-client-transaction.c @@ -940,6 +940,8 @@ void smtp_client_transaction_start( i_assert(mail != NULL); event_add_str(trans->event, "mail_from", smtp_address_encode(mail->mail_from)); + event_add_str(trans->event, "mail_from_raw", + smtp_address_encode_raw(mail->mail_from)); smtp_params_mail_add_to_event(&mail->mail_params, trans->event); diff --git a/src/lib-smtp/smtp-client.h b/src/lib-smtp/smtp-client.h index 489cdb44df..eb68d2f892 100644 --- a/src/lib-smtp/smtp-client.h +++ b/src/lib-smtp/smtp-client.h @@ -103,6 +103,9 @@ struct smtp_client_settings { bool xclient_defer; /* don't clear password after first successful authentication */ bool remember_password; + /* sending even broken MAIL command path (otherwise a broken address + is sent as <>) */ + bool mail_send_broken_path; }; struct smtp_client *smtp_client_init(const struct smtp_client_settings *set);