]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-client - Add verbose_user_errors setting.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 7 Dec 2021 00:58:32 +0000 (01:58 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 10 Jan 2022 06:31:48 +0000 (06:31 +0000)
It returns the detailed administrator errors as user error in the reply returned
to the calling application.

src/lib-smtp/smtp-client-connection.c
src/lib-smtp/smtp-client.c
src/lib-smtp/smtp-client.h

index 6d938f4159da36149cec6372cc9696e2aeaf39c1..132914a588cc9e7ee3a91a12beacd022f07a578b 100644 (file)
@@ -381,7 +381,10 @@ void smtp_client_connection_fail(struct smtp_client_connection *conn,
 
        i_zero(&text_lines);
        i_assert(user_error != NULL);
-       text_lines[0] = user_error;
+       if (conn->set.verbose_user_errors && error != NULL)
+               text_lines[0] = error;
+       else
+               text_lines[0] = user_error;
 
        timeout_remove(&conn->to_connect);
 
@@ -2125,6 +2128,10 @@ smtp_client_connection_do_create(struct smtp_client *client, const char *name,
                conn->set.peer_trusted = set->peer_trusted;
 
                conn->set.mail_send_broken_path = set->mail_send_broken_path;
+
+               conn->set.verbose_user_errors =
+                       conn->set.verbose_user_errors ||
+                       set->verbose_user_errors;
        }
 
        if (set != NULL && set->extra_capabilities != NULL) {
index be62cbd09de27715d83bb57604636cd48e680123..653dd0ef189dd251ad3a90c29ad4fda1adb5fd80 100644 (file)
@@ -78,6 +78,7 @@ struct smtp_client *smtp_client_init(const struct smtp_client_settings *set)
        client->set.socket_send_buffer_size = set->socket_send_buffer_size;
        client->set.socket_recv_buffer_size = set->socket_recv_buffer_size;
        client->set.debug = set->debug;
+       client->set.verbose_user_errors = set->verbose_user_errors;
 
        smtp_proxy_data_merge(pool, &client->set.proxy_data, &set->proxy_data);
 
index 3fdc5c63fdd8193c9e50c5660239ede97837e605..75608e99550db0fb2c759b7efc61898893448b6b 100644 (file)
@@ -115,6 +115,9 @@ struct smtp_client_settings {
        /* sending even broken MAIL command path (otherwise a broken address
           is sent as <>) */
        bool mail_send_broken_path;
+       /* Yield verbose user-visible errors for commands and connections that
+          failed locally. */
+       bool verbose_user_errors;
 };
 
 struct smtp_client *smtp_client_init(const struct smtp_client_settings *set);