]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
submssion: submission-backend-relay - Avoid logging two errors about a connection...
authorStephan Bosch <stephan.bosch@open-xchange.com>
Mon, 13 Dec 2021 03:08:32 +0000 (04:08 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 10 Jan 2022 06:31:48 +0000 (06:31 +0000)
Earlier commit changed lib-smtp to consistently log an error for connection
problems, which causes a second error to occur for submission relay backend.
This is undesirable.

src/submission/submission-backend-relay.c

index b29ec080e5990ca9450a5d032a59975a22f7a26f..cc8a6797f8884a3cdf6bde86d86f265fca154fe9 100644 (file)
@@ -47,6 +47,8 @@ backend_relay_handle_relay_reply(struct submission_backend_relay *backend,
                                 const struct smtp_reply *reply,
                                 struct smtp_reply *reply_r) ATTR_NULL(2)
 {
+       struct client *client = backend->backend.client;
+       struct mail_user *user = client->user;
        const char *enh_code, *msg, *log_msg = NULL;
        const char *const *reply_lines;
        bool result = TRUE;
@@ -126,8 +128,15 @@ backend_relay_handle_relay_reply(struct submission_backend_relay *backend,
 
                reason = t_strdup_printf("%s%s", msg, detail);
                smtp_client_transaction_destroy(&backend->trans);
-               if (log_msg != NULL)
-                       i_error("%s: %s", log_msg, smtp_reply_log(reply));
+               if (log_msg != NULL) {
+                       if (smtp_reply_is_remote(reply)) {
+                               i_error("%s: %s",
+                                       log_msg, smtp_reply_log(reply));
+                       } else if (user->mail_debug) {
+                               i_debug("%s: %s",
+                                       log_msg, smtp_reply_log(reply));
+                       }
+               }
                submission_backend_fail(&backend->backend, cmd,
                                        enh_code, reason);
                return FALSE;