From 1a47b633600e808a11d75551306a2bf8ebf87335 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 10 Nov 2015 23:12:26 +0000 Subject: Logging: support +outgoing_port on defer lines and per-host error lines --- src/src/deliver.c | 8 ++++++++ src/src/transports/smtp.c | 23 +++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/src/deliver.c b/src/src/deliver.c index f3ae2208a..e1f4e0e29 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -1288,9 +1288,17 @@ else if (result == DEFER || result == PANIC) US strerror(addr->basic_errno)); if (addr->host_used) + { s = string_append(s, &size, &ptr, 5, US" H=", addr->host_used->name, US" [", addr->host_used->address, US"]"); + if (LOGGING(outgoing_port)) + { + int port = addr->host_used->port; + s = string_append(s, &size, &ptr, 2, + US":", port == PORT_NONE ? US"25" : string_sprintf("%d", port)); + } + } if (addr->message) s = string_append(s, &size, &ptr, 2, US": ", addr->message); diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index eae54764b..59afe42aa 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -655,6 +655,9 @@ write_logs(address_item *addr, host_item *host) { uschar * message = string_sprintf("H=%s [%s]", host->name, host->address); +if (LOGGING(outgoing_port)) + message = string_sprintf("%s:%d", message, + host->port == PORT_NONE ? 25 : host->port); if (addr->message) { message = string_sprintf("%s: %s", message, addr->message); @@ -665,9 +668,6 @@ if (addr->message) } else { - if (LOGGING(outgoing_port)) - message = string_sprintf("%s:%d", message, - host->port == PORT_NONE ? 25 : host->port); log_write(0, LOG_MAIN, "%s %s", message, strerror(addr->basic_errno)); deliver_msglog("%s %s %s\n", tod_stamp(tod_log), message, strerror(addr->basic_errno)); @@ -3618,15 +3618,14 @@ for (cutoff_retry = 0; expired && host_item *h; DEBUG(D_transport) debug_printf("hosts_max_try limit reached with this host\n"); - for (h = host; h != NULL; h = h->next) - if (h->mx != host->mx) break; - if (h != NULL) - { - nexthost = h; - unexpired_hosts_tried--; - DEBUG(D_transport) debug_printf("however, a higher MX host exists " - "and will be tried\n"); - } + for (h = host; h; h = h->next) if (h->mx != host->mx) + { + nexthost = h; + unexpired_hosts_tried--; + DEBUG(D_transport) debug_printf("however, a higher MX host exists " + "and will be tried\n"); + break; + } } /* Attempt the delivery. */ -- cgit v1.2.3