- /* Can we re-use an open cutthrough connection? */
- if ( cutthrough.fd >= 0
- && (options & (vopt_callout_recipsender | vopt_callout_recippmaster))
- == vopt_callout_recipsender
- && !random_local_part
- && !pm_mailfrom
- )
- {
- if (addr->transport == cutthrough.addr.transport)
- for (host = host_list; host; host = host->next)
- if (Ustrcmp(host->address, cutthrough.host.address) == 0)
- {
- int host_af;
- uschar *interface = NULL; /* Outgoing interface to use; NULL => any */
- int port = 25;
-
- deliver_host = host->name;
- deliver_host_address = host->address;
- deliver_host_port = host->port;
- deliver_domain = addr->domain;
- transport_name = addr->transport->name;
-
- host_af = (Ustrchr(host->address, ':') == NULL)? AF_INET:AF_INET6;
-
- if (!smtp_get_interface(tf->interface, host_af, addr, &interface,
- US"callout") ||
- !smtp_get_port(tf->port, addr, &port, US"callout"))
- log_write(0, LOG_MAIN|LOG_PANIC, "<%s>: %s", addr->address,
- addr->message);
-
- if ( ( interface == cutthrough.interface
- || ( interface
- && cutthrough.interface
- && Ustrcmp(interface, cutthrough.interface) == 0
- ) )
- && port == cutthrough.host.port
- )
- {
- uschar * resp = NULL;
-
- /* Match! Send the RCPT TO, append the addr, set done */
- done =
- smtp_write_command(&ctblock, FALSE, "RCPT TO:<%.1000s>\r\n",
- transport_rcpt_address(addr,
- (addr->transport == NULL)? FALSE :
- addr->transport->rcpt_include_affixes)) >= 0 &&
- cutthrough_response('2', &resp) == '2';
-
- /* This would go horribly wrong if a callout fail was ignored by ACL.
- We punt by abandoning cutthrough on a reject, like the
- first-rcpt does. */
-
- if (done)
- {
- address_item * na = store_get(sizeof(address_item));
- *na = cutthrough.addr;
- cutthrough.addr = *addr;
- cutthrough.addr.host_used = &cutthrough.host;
- cutthrough.addr.next = na;
-
- cutthrough.nrcpt++;
- }
- else
- {
- cancel_cutthrough_connection("recipient rejected");
- if (!resp || errno == ETIMEDOUT)
- {
- HDEBUG(D_verify) debug_printf("SMTP timeout\n");
- }
- else if (errno == 0)
- {
- if (*resp == 0)
- Ustrcpy(resp, US"connection dropped");
-
- addr->message =
- string_sprintf("response to \"%s\" from %s [%s] was: %s",
- big_buffer, host->name, host->address,
- string_printing(resp));
-
- addr->user_message =
- string_sprintf("Callout verification failed:\n%s", resp);