1
/* $Cambridge: exim/exim-src/src/transports/smtp.c,v 1.13 2005/06/29 14:17:01 ph10 Exp $ */
1
3
/*************************************************
2
4
* Exim - an Internet mail transport agent *
3
5
*************************************************/
5
/* Copyright (c) University of Cambridge 1995 - 2004 */
7
/* Copyright (c) University of Cambridge 1995 - 2005 */
6
8
/* See the file NOTICE for conditions of use and distribution. */
8
10
#include "../exim.h"
33
35
(void *)offsetof(smtp_transport_options_block, data_timeout) },
34
36
{ "delay_after_cutoff", opt_bool,
35
37
(void *)offsetof(smtp_transport_options_block, delay_after_cutoff) },
38
#ifdef EXPERIMENTAL_DOMAINKEYS
39
{ "dk_canon", opt_stringptr,
40
(void *)offsetof(smtp_transport_options_block, dk_canon) },
41
{ "dk_domain", opt_stringptr,
42
(void *)offsetof(smtp_transport_options_block, dk_domain) },
43
{ "dk_headers", opt_stringptr,
44
(void *)offsetof(smtp_transport_options_block, dk_headers) },
45
{ "dk_private_key", opt_stringptr,
46
(void *)offsetof(smtp_transport_options_block, dk_private_key) },
47
{ "dk_selector", opt_stringptr,
48
(void *)offsetof(smtp_transport_options_block, dk_selector) },
49
{ "dk_strict", opt_stringptr,
50
(void *)offsetof(smtp_transport_options_block, dk_strict) },
36
52
{ "dns_qualify_single", opt_bool,
37
53
(void *)offsetof(smtp_transport_options_block, dns_qualify_single) },
38
54
{ "dns_search_parents", opt_bool,
56
72
{ "hosts_max_try", opt_int,
57
73
(void *)offsetof(smtp_transport_options_block, hosts_max_try) },
74
{ "hosts_max_try_hardlimit", opt_int,
75
(void *)offsetof(smtp_transport_options_block, hosts_max_try_hardlimit) },
59
77
{ "hosts_nopass_tls", opt_stringptr,
60
78
(void *)offsetof(smtp_transport_options_block, hosts_nopass_tls) },
136
154
10*60, /* final timeout */
137
155
1024, /* size_addition */
138
156
5, /* hosts_max_try */
157
50, /* hosts_max_try_hardlimit */
139
158
FALSE, /* allow_localhost */
140
159
FALSE, /* gethostbyname */
141
160
TRUE, /* dns_qualify_single */
153
172
NULL, /* tls_verify_certificates */
154
173
TRUE /* tls_tempfail_tryclear */
175
#ifdef EXPERIMENTAL_DOMAINKEYS
176
,NULL, /* dk_canon */
177
NULL, /* dk_domain */
178
NULL, /* dk_headers */
179
NULL, /* dk_private_key */
180
NULL, /* dk_selector */
286
313
status means that an address is not currently being processed.
289
addrlist points to a chain of addresses
290
errno_value to put in each address's errno field
291
msg to put in each address's message field
292
rc to put in each address's transport_return field
316
addrlist points to a chain of addresses
317
errno_value to put in each address's errno field
318
msg to put in each address's message field
319
rc to put in each address's transport_return field
320
pass_message if TRUE, set the "pass message" flag in the address
294
322
If errno_value has the special value ERRNO_CONNECTTIMEOUT, ETIMEDOUT is put in
295
323
the errno field, and RTEF_CTOUT is ORed into the more_errno field, to indicate
302
void set_errno(address_item *addrlist, int errno_value, uschar *msg, int rc)
330
void set_errno(address_item *addrlist, int errno_value, uschar *msg, int rc,
304
333
address_item *addr;
313
342
if (addr->transport_return < PENDING) continue;
314
343
addr->basic_errno = errno_value;
315
344
addr->more_errno |= orvalue;
316
if (msg != NULL) addr->message = msg;
348
if (pass_message) setflag(addr, af_pass_message);
317
350
addr->transport_return = rc;
334
host the current host, to get its name for messages
335
errno_value pointer to the errno value
336
more_errno from the top address for use with ERRNO_FILTER_FAIL
337
buffer the SMTP response buffer
338
yield where to put a one-digit SMTP response code
339
message where to put an errror message
367
host the current host, to get its name for messages
368
errno_value pointer to the errno value
369
more_errno from the top address for use with ERRNO_FILTER_FAIL
370
buffer the SMTP response buffer
371
yield where to put a one-digit SMTP response code
372
message where to put an errror message
373
pass_message set TRUE if message is an SMTP response
341
Returns: TRUE if an SMTP "QUIT" command should be sent, else FALSE
375
Returns: TRUE if an SMTP "QUIT" command should be sent, else FALSE
344
378
static BOOL check_response(host_item *host, int *errno_value, int more_errno,
345
uschar *buffer, int *yield, uschar **message)
379
uschar *buffer, int *yield, uschar **message, BOOL *pass_message)
347
381
uschar *pl = US"";
388
422
if (*errno_value == ERRNO_FILTER_FAIL)
390
*message = US string_sprintf("transport filter process failed (%d)", more_errno);
424
*message = US string_sprintf("transport filter process failed (%d)%s",
426
(more_errno == EX_EXECFAILED)? ": unable to execute command" : "");
415
451
if (buffer[0] != 0)
417
453
uschar *s = string_printing(buffer);
418
*message = US string_sprintf("SMTP error from remote mailer after %s%s: "
454
*message = US string_sprintf("SMTP error from remote mail server after %s%s: "
419
455
"host %s [%s]: %s", pl, smtp_command, host->name, host->address, s);
456
*pass_message = TRUE;
420
457
*yield = buffer[0];
594
631
uschar *message = string_sprintf("SMTP timeout while connected to %s [%s] "
595
632
"after RCPT TO:<%s>", host->name, host->address,
596
633
transport_rcpt_address(addr, include_affixes));
597
set_errno(addrlist, save_errno, message, DEFER);
634
set_errno(addrlist, save_errno, message, DEFER, FALSE);
598
635
retry_add_item(addr, addr->address_retry_key, 0);
599
636
host->update_waiting = FALSE;
620
string_sprintf("SMTP error from remote mailer after RCPT TO:<%s>: "
657
string_sprintf("SMTP error from remote mail server after RCPT TO:<%s>: "
621
658
"host %s [%s]: %s", transport_rcpt_address(addr, include_affixes),
622
659
host->name, host->address, string_printing(buffer));
660
setflag(addr, af_pass_message);
623
661
deliver_msglog("%s %s\n", tod_stamp(tod_log), addr->message);
625
663
/* The response was 5xx */
675
int bincode = (buffer[1] - '0')*10 + buffer[2] - '0';
677
addr->transport_return = DEFER;
678
addr->basic_errno = ERRNO_RCPT4XX;
679
addr->more_errno |= bincode << 8;
637
681
/* Log temporary errors if there are more hosts to be tried. */
638
683
if (host->next != NULL) log_write(0, LOG_MAIN, "%s", addr->message);
639
addr->transport_return = DEFER;
641
685
/* Do not put this message on the list of those waiting for this host,
642
686
as otherwise it is likely to be tried too often. */
667
712
if (pending_DATA > 0 || (yield & 1) != 0) return -3;
668
(void)check_response(host, &errno, 0, buffer, &code, &msg);
713
(void)check_response(host, &errno, 0, buffer, &code, &msg, &pass_message);
669
714
DEBUG(D_transport) debug_printf("%s\nerror for DATA ignored: pipelining "
670
715
"is in use and there were no good recipients\n", msg);
690
735
Otherwise, we have to make a connection to the remote host, and do the
691
736
initial protocol exchange.
738
When running as an MUA wrapper, if the sender or any recipient is rejected,
739
temporarily or permanently, we force failure for all recipients.
694
742
addrlist chain of potential addresses to deliver; only those whose
695
743
transport_return field is set to PENDING_DEFER are currently
785
834
uschar *message = string_sprintf("failed to expand helo_data: %s",
786
835
expand_string_message);
787
set_errno(addrlist, 0, message, DEFER);
836
set_errno(addrlist, 0, message, DEFER, FALSE);
805
854
uschar *message = string_sprintf("failed to expand "
806
855
"authenticated_sender: %s", expand_string_message);
807
set_errno(addrlist, 0, message, DEFER);
856
set_errno(addrlist, 0, message, DEFER, FALSE);
877
if (!smtp_write_command(&outblock, FALSE, "%s %s\r\n",
878
lmtp? "LHLO" : "EHLO", helo_data))
926
if (smtp_write_command(&outblock, FALSE, "%s %s\r\n",
927
lmtp? "LHLO" : "EHLO", helo_data) < 0)
879
928
goto SEND_FAILED;
880
929
if (!smtp_read_response(&inblock, buffer, sizeof(buffer), '2',
881
930
ob->command_timeout))
895
if (!smtp_write_command(&outblock, FALSE, "HELO %s\r\n", helo_data))
944
if (smtp_write_command(&outblock, FALSE, "HELO %s\r\n", helo_data) < 0)
896
945
goto SEND_FAILED;
897
946
if (!smtp_read_response(&inblock, buffer, sizeof(buffer), '2',
898
947
ob->command_timeout)) goto RESPONSE_FAILED;
934
983
host->address, NULL) != OK)
936
985
uschar buffer2[4096];
937
if (!smtp_write_command(&outblock, FALSE, "STARTTLS\r\n")) goto SEND_FAILED;
986
if (smtp_write_command(&outblock, FALSE, "STARTTLS\r\n") < 0)
939
989
/* If there is an I/O error, transmission of this message is deferred. If
940
990
there is a temporary rejection of STARRTLS and tls_tempfail_tryclear is
982
1032
for (addr = addrlist; addr != NULL; addr = addr->next)
984
addr->cipher = tls_cipher;
985
addr->peerdn = tls_peerdn;
1034
if (addr->transport_return == PENDING_DEFER)
1036
addr->cipher = tls_cipher;
1037
addr->peerdn = tls_peerdn;
992
1045
if (tls_active >= 0)
994
if (!smtp_write_command(&outblock, FALSE, "%s %s\r\n", lmtp? "LHLO" : "EHLO",
1047
if (smtp_write_command(&outblock, FALSE, "%s %s\r\n", lmtp? "LHLO" : "EHLO",
996
1049
goto SEND_FAILED;
997
1050
if (!smtp_read_response(&inblock, buffer, sizeof(buffer), '2',
998
1051
ob->command_timeout))
1147
set_errno(addrlist, 0, string_copy(buffer), DEFER);
1200
set_errno(addrlist, 0, string_copy(buffer), DEFER, FALSE);
1148
1201
goto SEND_QUIT;
1162
1215
set_errno(addrlist, ERRNO_AUTHFAIL,
1163
string_sprintf("authentication required but %s", fail_reason), DEFER);
1216
string_sprintf("authentication required but %s", fail_reason), DEFER,
1164
1218
goto SEND_QUIT;
1189
set_errno(addrlist->next, addrlist->basic_errno, addrlist->message, DEFER);
1243
set_errno(addrlist->next, addrlist->basic_errno, addrlist->message, DEFER,
1191
1246
goto SEND_QUIT;
1263
1318
several before we have to read the responses for those seen so far. This
1264
1319
checking is done by a subroutine because it also needs to be done at the end.
1265
1320
Send only up to max_rcpt addresses at a time, leaving first_addr pointing to
1266
the next one if not all are sent. */
1321
the next one if not all are sent.
1323
In the MUA wrapper situation, we want to flush the PIPELINING buffer for the
1324
last address because we want to abort if any recipients have any kind of
1325
problem, temporary or permanent. We know that all recipient addresses will have
1326
the PENDING_DEFER status, because only one attempt is ever made, and we know
1327
that max_rcpt will be large, so all addresses will be done at once. */
1268
1329
for (addr = first_addr;
1269
1330
address_count < max_rcpt && addr != NULL;
1270
1331
addr = addr->next)
1274
1336
if (addr->transport_return != PENDING_DEFER) continue;
1276
1338
address_count++;
1339
no_flush = smtp_use_pipelining && (!mua_wrapper || addr->next != NULL);
1278
1341
/* Now send the RCPT command, and process outstanding responses when
1279
1342
necessary. After a timeout on RCPT, we just end the function, leaving the
1280
1343
yield as OK, because this error can often mean that there is a problem with
1281
1344
just one address, so we don't want to delay the host. */
1283
count = smtp_write_command(&outblock, smtp_use_pipelining,
1346
count = smtp_write_command(&outblock, no_flush, "RCPT TO:<%s>\r\n",
1285
1347
transport_rcpt_address(addr, tblock->rcpt_include_affixes));
1286
1348
if (count < 0) goto SEND_FAILED;
1307
1369
} /* Loop for next address */
1371
/* If we are an MUA wrapper, abort if any RCPTs were rejected, either
1372
permanently or temporarily. We should have flushed and synced after the last
1377
address_item *badaddr;
1378
for (badaddr = first_addr; badaddr != NULL; badaddr = badaddr->next)
1380
if (badaddr->transport_return != PENDING_OK) break;
1382
if (badaddr != NULL)
1384
set_errno(addrlist, 0, badaddr->message, FAIL,
1385
testflag(badaddr, af_pass_message));
1309
1390
/* If ok is TRUE, we know we have got at least one good recipient, and must now
1310
send DATA, but if it is FALSE, we may still have a good recipient buffered up
1311
if we are pipelining. We don't want to waste time sending DATA needlessly, so
1312
we only send it if either ok is TRUE or if we are pipelining. The responses are
1313
all handled by sync_responses(). */
1391
send DATA, but if it is FALSE (in the normal, non-wrapper case), we may still
1392
have a good recipient buffered up if we are pipelining. We don't want to waste
1393
time sending DATA needlessly, so we only send it if either ok is TRUE or if we
1394
are pipelining. The responses are all handled by sync_responses(). */
1315
if (ok || smtp_use_pipelining)
1396
if (ok || (smtp_use_pipelining && !mua_wrapper))
1317
1398
int count = smtp_write_command(&outblock, FALSE, "DATA\r\n");
1318
1399
if (count < 0) goto SEND_FAILED;
1352
1433
DEBUG(D_transport|D_v)
1353
1434
debug_printf(" SMTP>> writing message and terminating \".\"\n");
1354
1435
transport_count = 0;
1436
#ifdef EXPERIMENTAL_DOMAINKEYS
1437
if ( (ob->dk_private_key != NULL) && (ob->dk_selector != NULL) )
1438
ok = dk_transport_write_message(addrlist, inblock.sock,
1439
topt_use_crlf | topt_end_dot | topt_escape_headers |
1440
(tblock->body_only? topt_no_headers : 0) |
1441
(tblock->headers_only? topt_no_body : 0) |
1442
(tblock->return_path_add? topt_add_return_path : 0) |
1443
(tblock->delivery_date_add? topt_add_delivery_date : 0) |
1444
(tblock->envelope_to_add? topt_add_envelope_to : 0),
1445
0, /* No size limit */
1446
tblock->add_headers, tblock->remove_headers,
1447
US".", US"..", /* Escaping strings */
1448
tblock->rewrite_rules, tblock->rewrite_existflags,
1449
ob->dk_private_key, ob->dk_domain, ob->dk_selector,
1450
ob->dk_canon, ob->dk_headers, ob->dk_strict);
1355
1453
ok = transport_write_message(addrlist, inblock.sock,
1356
1454
topt_use_crlf | topt_end_dot | topt_escape_headers |
1357
1455
(tblock->body_only? topt_no_headers : 0) |
1515
1611
save_errno = errno;
1516
1612
message = NULL;
1517
1613
send_quit = check_response(host, &save_errno, addrlist->more_errno,
1518
buffer, &code, &message);
1614
buffer, &code, &message, &pass_message);
1522
1618
save_errno = errno;
1524
message = US string_sprintf("send() to %s [%s] failed",
1620
message = US string_sprintf("send() to %s [%s] failed: %s",
1525
1621
host->name, host->address, strerror(save_errno));
1526
1622
send_quit = FALSE;
1551
1647
if (code == '5')
1553
set_errno(addrlist, save_errno, message, FAIL);
1649
set_errno(addrlist, save_errno, message, FAIL, pass_message);
1557
set_errno(addrlist, save_errno, message, DEFER);
1653
set_errno(addrlist, save_errno, message, DEFER, pass_message);
1581
1677
yield = (save_errno == ERRNO_CHHEADER_FAIL ||
1582
1678
save_errno == ERRNO_FILTER_FAIL)? ERROR : DEFER;
1583
set_errno(addrlist, save_errno, message, DEFER);
1679
set_errno(addrlist, save_errno, message, DEFER, pass_message);
1586
1682
/* Otherwise we have a message-specific error response from the remote
1602
set_errno(addrlist, save_errno, message, (code == '5')? FAIL : DEFER);
1698
if (mua_wrapper) code = '5'; /* Force hard failure in wrapper mode */
1700
set_errno(addrlist, save_errno, message, (code == '5')? FAIL : DEFER,
1604
1703
/* If there's an errno, the message contains just the identity of
1647
1746
DEBUG(D_transport)
1648
1747
debug_printf("ok=%d send_quit=%d send_rset=%d continue_more=%d "
1649
"yield=%d first_address=%d\n", ok, send_quit, send_rset, continue_more,
1650
yield, (int)first_addr);
1748
"yield=%d first_address is %sNULL\n", ok, send_quit, send_rset,
1749
continue_more, yield, (first_addr == NULL)? "":"not ");
1652
1751
if (completed_address && ok && send_quit)
1669
if (! (ok = smtp_write_command(&outblock, FALSE, "RSET\r\n")))
1769
if (! (ok = smtp_write_command(&outblock, FALSE, "RSET\r\n") >= 0))
1671
msg = US string_sprintf("send() to %s [%s] failed", host->name,
1771
msg = US string_sprintf("send() to %s [%s] failed: %s", host->name,
1672
1772
host->address, strerror(save_errno));
1673
1773
send_quit = FALSE;
1676
1776
ob->command_timeout)))
1679
send_quit = check_response(host, &errno, 0, buffer, &code, &msg);
1779
send_quit = check_response(host, &errno, 0, buffer, &code, &msg,
1680
1781
if (!send_quit)
1682
1783
DEBUG(D_transport) debug_printf("%s\n", msg);
1704
1805
if (tls_active >= 0)
1706
1807
tls_close(TRUE);
1707
ok = smtp_write_command(&outblock, FALSE, "EHLO %s\r\n", helo_data) &&
1808
ok = smtp_write_command(&outblock,FALSE,"EHLO %s\r\n",helo_data) >= 0 &&
1708
1809
smtp_read_response(&inblock, buffer, sizeof(buffer), '2',
1709
1810
ob->command_timeout);
1723
1824
/* If RSET failed and there are addresses left, they get deferred. */
1725
else set_errno(first_addr, errno, msg, DEFER);
1826
else set_errno(first_addr, errno, msg, DEFER, FALSE);
1745
1846
operation, the old commented-out code was removed on 17-Sep-99. */
1748
if (send_quit) (void) smtp_write_command(&outblock, FALSE, "QUIT\r\n");
1849
if (send_quit) (void)smtp_write_command(&outblock, FALSE, "QUIT\r\n");
1765
1866
specified in the transports, and therefore not visible at top level, in which
1766
1867
case continue_more won't get set. */
1768
close(inblock.sock);
1869
(void)close(inblock.sock);
1769
1870
continue_transport = NULL;
1770
1871
continue_hostname = NULL;
1815
1916
outblock.cmd_count = 0;
1816
1917
outblock.authenticating = FALSE;
1818
smtp_write_command(&outblock, FALSE, "QUIT\r\n");
1819
(void) smtp_read_response(&inblock, buffer, sizeof(buffer), '2',
1919
(void)smtp_write_command(&outblock, FALSE, "QUIT\r\n");
1920
(void)smtp_read_response(&inblock, buffer, sizeof(buffer), '2',
1820
1921
ob->command_timeout);
1821
close(inblock.sock);
1922
(void)close(inblock.sock);
2053
2155
. If there are any addresses whose status is still DEFER, carry on to the
2054
2156
next host/IPaddress, unless we have tried the number of hosts given
2055
by hosts_max_try; otherwise return.
2157
by hosts_max_try or hosts_max_try_hardlimit; otherwise return. Note that
2158
there is some fancy logic for hosts_max_try that means its limit can be
2159
overstepped in some circumstances.
2057
2161
If we get to the end of the list, all hosts have deferred at least one address,
2058
2162
or not reached their retry times. If delay_after_cutoff is unset, it requests a
2087
2193
uschar *serialize_key = NULL;
2089
2195
/* Default next host is next host. :-) But this can vary if the
2090
hosts_max_try limit is hit (see below). */
2196
hosts_max_try limit is hit (see below). It may also be reset if a host
2197
address is looked up here (in case the host was multihomed). */
2092
2199
nexthost = host->next;
2130
2237
/* Find by name if so configured, or if it's an IP address. We don't
2131
2238
just copy the IP address, because we need the test-for-local to happen. */
2133
if (ob->gethostbyname || string_is_ip_address(host->name, NULL))
2240
if (ob->gethostbyname || string_is_ip_address(host->name, NULL) > 0)
2134
2241
rc = host_find_byname(host, NULL, &canonical_name, TRUE);
2136
rc = host_find_bydns(host, NULL, HOST_FIND_BY_A, NULL,
2137
ob->dns_qualify_single, ob->dns_search_parents,
2244
int flags = HOST_FIND_BY_A;
2245
if (ob->dns_qualify_single) flags |= HOST_FIND_QUALIFY_SINGLE;
2246
if (ob->dns_search_parents) flags |= HOST_FIND_SEARCH_PARENTS;
2247
rc = host_find_bydns(host, NULL, flags, NULL, NULL, NULL,
2138
2248
&canonical_name, NULL);
2140
2251
/* Failure to find the host at this time (usually DNS temporary failure)
2141
2252
is really a kind of routing failure rather than a transport failure.
2193
2304
continue; /* With next host */
2307
/* Reset the default next host in case a multihomed host whose addresses
2308
are not looked up till just above added to the host list. */
2310
nexthost = host->next;
2196
2312
/* If queue_smtp is set (-odqs or the first part of a 2-stage run), or the
2197
2313
domain is in queue_smtp_domains, we don't actually want to attempt any
2198
2314
deliveries. When doing a queue run, queue_smtp_domains is always unset. If
2350
2466
if (dont_deliver)
2352
2468
host_item *host2;
2353
set_errno(addrlist, 0, NULL, OK);
2469
set_errno(addrlist, 0, NULL, OK, FALSE);
2354
2470
for (addr = addrlist; addr != NULL; addr = addr->next)
2356
2472
addr->host_used = host;
2371
2487
/* This is for real. If the host is expired, we don't count it for
2372
2488
hosts_max_retry. This ensures that all hosts must expire before an address
2373
is timed out. Otherwise, if we are about to hit the hosts_max_retry limit,
2374
check to see if there is a subsequent hosts with a different MX value. If
2375
so, make that the next host, and don't count this one. This is a heuristic
2376
to make sure that different MXs do get tried. With a normal kind of retry
2377
rule, they would get tried anyway when the earlier hosts were delayed, but
2378
if the domain has a "retry every time" type of rule - as is often used for
2379
the the very large ISPs, that won't happen. */
2489
is timed out, unless hosts_max_try_hardlimit (which protects against
2490
lunatic DNS configurations) is reached.
2492
If the host is not expired and we are about to hit the hosts_max_retry
2493
limit, check to see if there is a subsequent hosts with a different MX
2494
value. If so, make that the next host, and don't count this one. This is a
2495
heuristic to make sure that different MXs do get tried. With a normal kind
2496
of retry rule, they would get tried anyway when the earlier hosts were
2497
delayed, but if the domain has a "retry every time" type of rule - as is
2498
often used for the the very large ISPs, that won't happen. */
2399
2518
/* Attempt the delivery. */
2520
total_hosts_tried++;
2401
2521
rc = smtp_deliver(addrlist, host, host_af, port, interface, tblock,
2402
2522
expanded_hosts != NULL, &message_defer, FALSE);
2563
2683
maximum retry time for this host. This means we may try try all hosts,
2564
2684
ignoring the limit, when messages have been around for some time. This is
2565
2685
important because if we don't try all hosts, the address will never time
2686
out. NOTE: this does not apply to hosts_max_try_hardlimit. */
2568
2688
if ((rc == DEFER || some_deferred) && nexthost != NULL)
2605
/* Get here if all IP addresses are skipped or defer at least one address. Add
2606
a standard message to each deferred address if there hasn't been an error, that
2607
is, if it hasn't actually been tried this time. The variable "expired" will be
2608
FALSE if any deliveries were actually tried, or if there was at least one host
2609
that was not expired. That is, it is TRUE only if no deliveries were tried and
2610
all hosts were expired. If a delivery has been tried, an error code will be
2611
set, and the failing of the message is handled by the retry code later.
2725
/* Get here if all IP addresses are skipped or defer at least one address. In
2726
MUA wrapper mode, this will happen only for connection or other non-message-
2727
specific failures. Force the delivery status for all addresses to FAIL. */
2731
for (addr = addrlist; addr != NULL; addr = addr->next)
2732
addr->transport_return = FAIL;
2736
/* In the normal, non-wrapper case, add a standard message to each deferred
2737
address if there hasn't been an error, that is, if it hasn't actually been
2738
tried this time. The variable "expired" will be FALSE if any deliveries were
2739
actually tried, or if there was at least one host that was not expired. That
2740
is, it is TRUE only if no deliveries were tried and all hosts were expired. If
2741
a delivery has been tried, an error code will be set, and the failing of the
2742
message is handled by the retry code later.
2613
2744
If queue_smtp is set, or this transport was called to send a subsequent message
2614
2745
down an existing TCP/IP connection, and something caused the host not to be
2617
2748
for (addr = addrlist; addr != NULL; addr = addr->next)
2619
2750
/* If host is not NULL, it means that we stopped processing the host list
2620
because of hosts_max_try. This means we need to behave as if some hosts were
2621
skipped because their retry time had not come. Specifically, this prevents
2622
the address from timing out. */
2751
because of hosts_max_try or hosts_max_try_hardlimit. In the former case, this
2752
means we need to behave as if some hosts were skipped because their retry
2753
time had not come. Specifically, this prevents the address from timing out.
2754
However, if we have hit hosts_max_try_hardlimit, we want to behave as if all
2755
hosts were tried. */
2624
2757
if (host != NULL)
2627
debug_printf("hosts_max_try limit caused some hosts to be skipped\n");
2628
setflag(addr, af_retry_skipped);
2759
if (total_hosts_tried >= ob->hosts_max_try_hardlimit)
2762
debug_printf("hosts_max_try_hardlimit reached: behave as if all "
2763
"hosts were tried\n");
2768
debug_printf("hosts_max_try limit caused some hosts to be skipped\n");
2769
setflag(addr, af_retry_skipped);
2631
2773
if (queue_smtp) /* no deliveries attempted */
2647
2789
else if (expired)
2791
setflag(addr, af_pass_message); /* This is not a security risk */
2649
2792
addr->message = (ob->delay_after_cutoff)?
2650
2793
US"retry time not reached for any host after a long failure period" :
2651
2794
US"all hosts have been failing for a long time and were last tried "