1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) University of Cambridge 1995 - 2018 */
6 /* Copyright (c) The Exim Maintainers 2020 - 2021 */
7 /* See the file NOTICE for conditions of use and distribution. */
9 /* A number of functions for driving outgoing SMTP calls. */
13 #include "transports/smtp.h"
17 /*************************************************
18 * Find an outgoing interface *
19 *************************************************/
21 /* This function is called from the smtp transport and also from the callout
22 code in verify.c. Its job is to expand a string to get a list of interfaces,
23 and choose a suitable one (IPv4 or IPv6) for the outgoing address.
26 istring string interface setting, may be NULL, meaning "any", in
27 which case the function does nothing
28 host_af AF_INET or AF_INET6 for the outgoing IP address
29 addr the mail address being handled (for setting errors)
30 interface point this to the interface if there is one defined
31 msg to add to any error message
33 Returns: TRUE on success, FALSE on failure, with error message
34 set in addr and transport_return set to PANIC
38 smtp_get_interface(uschar *istring, int host_af, address_item *addr,
39 uschar **interface, uschar *msg)
41 const uschar * expint;
45 if (!istring) return TRUE;
47 if (!(expint = expand_string(istring)))
49 if (f.expand_string_forcedfail) return TRUE;
50 addr->transport_return = PANIC;
51 addr->message = string_sprintf("failed to expand \"interface\" "
52 "option for %s: %s", msg, expand_string_message);
56 if (is_tainted(expint))
58 log_write(0, LOG_MAIN|LOG_PANIC,
59 "attempt to use tainted value '%s' from '%s' for interface",
61 addr->transport_return = PANIC;
62 addr->message = string_sprintf("failed to expand \"interface\" "
63 "option for %s: configuration error", msg);
67 Uskip_whitespace(&expint);
68 if (!*expint) return TRUE;
70 while ((iface = string_nextinlist(&expint, &sep, NULL, 0)))
72 int if_af = string_is_ip_address(iface, NULL);
75 addr->transport_return = PANIC;
76 addr->message = string_sprintf("\"%s\" is not a valid IP "
77 "address for the \"interface\" option for %s",
82 if ((if_af == 4 ? AF_INET : AF_INET6) == host_af)
92 /*************************************************
93 * Find an outgoing port *
94 *************************************************/
96 /* This function is called from the smtp transport and also from the callout
97 code in verify.c. Its job is to find a port number. Note that getservbyname()
98 produces the number in network byte order.
101 rstring raw (unexpanded) string representation of the port
102 addr the mail address being handled (for setting errors)
103 port stick the port in here
104 msg for adding to error message
106 Returns: TRUE on success, FALSE on failure, with error message set
107 in addr, and transport_return set to PANIC
111 smtp_get_port(uschar *rstring, address_item *addr, int *port, uschar *msg)
113 uschar *pstring = expand_string(rstring);
117 addr->transport_return = PANIC;
118 addr->message = string_sprintf("failed to expand \"%s\" (\"port\" option) "
119 "for %s: %s", rstring, msg, expand_string_message);
123 if (isdigit(*pstring))
126 *port = Ustrtol(pstring, &end, 0);
127 if (end != pstring + Ustrlen(pstring))
129 addr->transport_return = PANIC;
130 addr->message = string_sprintf("invalid port number for %s: %s", msg,
138 struct servent *smtp_service = getservbyname(CS pstring, "tcp");
141 addr->transport_return = PANIC;
142 addr->message = string_sprintf("TCP port \"%s\" is not defined for %s",
146 *port = ntohs(smtp_service->s_port);
156 /* Try to record if TFO was attmepted and if it was successfully used. */
159 tfo_out_check(int sock)
161 static BOOL done_once = FALSE;
163 if (done_once) return;
167 struct tcp_info tinfo;
168 socklen_t len = sizeof(tinfo);
170 /* A getsockopt TCP_FASTOPEN unfortunately returns "was-used" for a TFO/R as
171 well as a TFO/C. Use what we can of the Linux hack below; reliability issues ditto. */
172 switch (tcp_out_fastopen)
174 case TFO_ATTEMPTED_NODATA:
175 if ( getsockopt(sock, IPPROTO_TCP, TCP_INFO, &tinfo, &len) == 0
176 && tinfo.tcpi_state == TCPS_SYN_SENT
177 && tinfo.__tcpi_unacked > 0
180 DEBUG(D_transport|D_v)
181 debug_printf("TCP_FASTOPEN tcpi_unacked %d\n", tinfo.__tcpi_unacked);
182 tcp_out_fastopen = TFO_USED_NODATA;
186 case TFO_ATTEMPTED_DATA:
187 case TFO_ATTEMPTED_DATA:
188 if (tinfo.tcpi_options & TCPI_OPT_SYN_DATA) XXX no equvalent as of 12.2
192 switch (tcp_out_fastopen)
194 case TFO_ATTEMPTED_DATA: tcp_out_fastopen = TFO_USED_DATA; break;
195 default: break; /* compiler quietening */
198 # else /* Linux & Apple */
199 # if defined(TCP_INFO) && defined(EXIM_HAVE_TCPI_UNACKED)
200 struct tcp_info tinfo;
201 socklen_t len = sizeof(tinfo);
203 switch (tcp_out_fastopen)
205 /* This is a somewhat dubious detection method; totally undocumented so likely
206 to fail in future kernels. There seems to be no documented way. What we really
207 want to know is if the server sent smtp-banner data before our ACK of his SYN,ACK
208 hit him. What this (possibly?) detects is whether we sent a TFO cookie with our
209 SYN, as distinct from a TFO request. This gets a false-positive when the server
210 key is rotated; we send the old one (which this test sees) but the server returns
211 the new one and does not send its SMTP banner before we ACK his SYN,ACK.
212 To force that rotation case:
213 '# echo -n "00000000-00000000-00000000-0000000" >/proc/sys/net/ipv4/tcp_fastopen_key'
214 The kernel seems to be counting unack'd packets. */
216 case TFO_ATTEMPTED_NODATA:
217 if ( getsockopt(sock, IPPROTO_TCP, TCP_INFO, &tinfo, &len) == 0
218 && tinfo.tcpi_state == TCP_SYN_SENT
219 && tinfo.tcpi_unacked > 1
222 DEBUG(D_transport|D_v)
223 debug_printf("TCP_FASTOPEN tcpi_unacked %d\n", tinfo.tcpi_unacked);
224 tcp_out_fastopen = TFO_USED_NODATA;
228 /* When called after waiting for received data we should be able
229 to tell if data we sent was accepted. */
231 case TFO_ATTEMPTED_DATA:
232 if ( getsockopt(sock, IPPROTO_TCP, TCP_INFO, &tinfo, &len) == 0
233 && tinfo.tcpi_state == TCP_ESTABLISHED
235 if (tinfo.tcpi_options & TCPI_OPT_SYN_DATA)
237 DEBUG(D_transport|D_v) debug_printf("TFO: data was acked\n");
238 tcp_out_fastopen = TFO_USED_DATA;
242 DEBUG(D_transport|D_v) debug_printf("TFO: had to retransmit\n");
243 tcp_out_fastopen = TFO_NOT_USED;
247 default: break; /* compiler quietening */
250 # endif /* Linux & Apple */
256 host host item containing name and address and port
257 host_af AF_INET or AF_INET6
259 interface outgoing interface address or NULL
261 timeout timeout value or 0
262 early_data if non-NULL, idempotent data to be sent -
263 preferably in the TCP SYN segment
264 Special case: non-NULL but with NULL blob.data - caller is
265 client-data-first (eg. TLS-on-connect) and a lazy-TCP-connect is
268 Returns: connected socket number, or -1 with errno set
272 smtp_sock_connect(host_item * host, int host_af, int port, uschar * interface,
273 transport_instance * tb, int timeout, const blob * early_data)
275 smtp_transport_options_block * ob =
276 (smtp_transport_options_block *)tb->options_block;
277 const uschar * dscp = ob->dscp;
283 const blob * fastopen_blob = NULL;
286 #ifndef DISABLE_EVENT
287 deliver_host_address = host->address;
288 deliver_host_port = port;
289 if (event_raise(tb->event_action, US"tcp:connect", NULL, &errno)) return -1;
292 if ((sock = ip_socket(SOCK_STREAM, host_af)) < 0) return -1;
294 /* Set TCP_NODELAY; Exim does its own buffering. */
296 if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, US &on, sizeof(on)))
297 HDEBUG(D_transport|D_acl|D_v)
298 debug_printf_indent("failed to set NODELAY: %s ", strerror(errno));
300 /* Set DSCP value, if we can. For now, if we fail to set the value, we don't
301 bomb out, just log it and continue in default traffic class. */
303 if (dscp && dscp_lookup(dscp, host_af, &dscp_level, &dscp_option, &dscp_value))
305 HDEBUG(D_transport|D_acl|D_v)
306 debug_printf_indent("DSCP \"%s\"=%x ", dscp, dscp_value);
307 if (setsockopt(sock, dscp_level, dscp_option, &dscp_value, sizeof(dscp_value)) < 0)
308 HDEBUG(D_transport|D_acl|D_v)
309 debug_printf_indent("failed to set DSCP: %s ", strerror(errno));
310 /* If the kernel supports IPv4 and IPv6 on an IPv6 socket, we need to set the
311 option for both; ignore failures here */
312 if (host_af == AF_INET6 &&
313 dscp_lookup(dscp, AF_INET, &dscp_level, &dscp_option, &dscp_value))
314 (void) setsockopt(sock, dscp_level, dscp_option, &dscp_value, sizeof(dscp_value));
317 /* Bind to a specific interface if requested. Caller must ensure the interface
318 is the same type (IPv4 or IPv6) as the outgoing address. */
320 if (interface && ip_bind(sock, host_af, interface, 0) < 0)
323 HDEBUG(D_transport|D_acl|D_v)
324 debug_printf_indent("unable to bind outgoing SMTP call to %s: %s", interface,
328 /* Connect to the remote host, and add keepalive to the socket before returning
329 it, if requested. If the build supports TFO, request it - and if the caller
330 requested some early-data then include that in the TFO request. If there is
331 early-data but no TFO support, send it after connecting. */
336 /* See if TCP Fast Open usable. Default is a traditional 3WHS connect */
337 if (verify_check_given_host(CUSS &ob->hosts_try_fastopen, host) == OK)
340 fastopen_blob = &tcp_fastopen_nodata; /* TFO, with no data */
341 else if (early_data->data)
342 fastopen_blob = early_data; /* TFO, with data */
343 # ifdef TCP_FASTOPEN_CONNECT
345 { /* expecting client data */
346 debug_printf(" set up lazy-connect\n");
347 setsockopt(sock, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, US &on, sizeof(on));
348 /* fastopen_blob = NULL; lazy TFO, triggered by data write */
354 if (ip_connect(sock, host_af, host->address, port, timeout, fastopen_blob) < 0)
356 else if (early_data && !fastopen_blob && early_data->data && early_data->len)
358 /* We had some early-data to send, but couldn't do TFO */
359 HDEBUG(D_transport|D_acl|D_v)
360 debug_printf("sending %ld nonTFO early-data\n", (long)early_data->len);
362 #ifdef TCP_QUICKACK_notdef
363 (void) setsockopt(sock, IPPROTO_TCP, TCP_QUICKACK, US &off, sizeof(off));
365 if (send(sock, early_data->data, early_data->len, 0) < 0)
368 #ifdef TCP_QUICKACK_notdef
369 /* Under TFO (with openssl & pipe-conn; testcase 4069, as of
370 5.10.8-100.fc32.x86_64) this seems to be inop.
371 Perhaps overwritten when we (client) go -> ESTABLISHED on seeing the 3rd-ACK?
372 For that case, added at smtp_reap_banner(). */
373 (void) setsockopt(sock, IPPROTO_TCP, TCP_QUICKACK, US &off, sizeof(off));
377 /* Either bind() or connect() failed */
381 HDEBUG(D_transport|D_acl|D_v)
383 debug_printf_indent(" failed: %s", CUstrerror(save_errno));
384 if (save_errno == ETIMEDOUT)
385 debug_printf(" (timeout=%s)", readconf_printtime(timeout));
393 /* Both bind() and connect() succeeded, and any early-data */
397 union sockaddr_46 interface_sock;
398 EXIM_SOCKLEN_T size = sizeof(interface_sock);
400 HDEBUG(D_transport|D_acl|D_v) debug_printf_indent(" connected\n");
401 if (getsockname(sock, (struct sockaddr *)(&interface_sock), &size) == 0)
402 sending_ip_address = host_ntoa(-1, &interface_sock, NULL, &sending_port);
405 log_write(0, LOG_MAIN | ((errno == ECONNRESET)? 0 : LOG_PANIC),
406 "getsockname() failed: %s", strerror(errno));
411 if (ob->keepalive) ip_keepalive(sock, host->address, TRUE);
424 smtp_port_for_connect(host_item * host, int port)
426 if (host->port != PORT_NONE)
428 HDEBUG(D_transport|D_acl|D_v) if (port != host->port)
429 debug_printf_indent("Transport port=%d replaced by host-specific port=%d\n", port,
433 else host->port = port; /* Set the port actually used */
437 /*************************************************
438 * Connect to remote host *
439 *************************************************/
441 /* Create a socket, and connect it to a remote host. IPv6 addresses are
442 detected by checking for a colon in the address. AF_INET6 is defined even on
443 non-IPv6 systems, to enable the code to be less messy. However, on such systems
444 host->address will always be an IPv4 address.
447 sc details for making connection: host, af, interface, transport
448 early_data if non-NULL, data to be sent - preferably in the TCP SYN segment
449 Special case: non-NULL but with NULL blob.data - caller is
450 client-data-first (eg. TLS-on-connect) and a lazy-TCP-connect is
453 Returns: connected socket number, or -1 with errno set
457 smtp_connect(smtp_connect_args * sc, const blob * early_data)
459 int port = sc->host->port;
460 smtp_transport_options_block * ob = sc->ob;
462 callout_address = string_sprintf("[%s]:%d", sc->host->address, port);
464 HDEBUG(D_transport|D_acl|D_v)
467 if (sc->interface) s = string_sprintf(" from %s ", sc->interface);
469 if (ob->socks_proxy) s = string_sprintf("%svia proxy ", s);
471 debug_printf_indent("Connecting to %s %s%s... ", sc->host->name, callout_address, s);
474 /* Create and connect the socket */
479 int sock = socks_sock_connect(sc->host, sc->host_af, port, sc->interface,
480 sc->tblock, ob->connect_timeout);
484 if (early_data && early_data->data && early_data->len)
485 if (send(sock, early_data->data, early_data->len, 0) < 0)
487 int save_errno = errno;
488 HDEBUG(D_transport|D_acl|D_v)
490 debug_printf_indent("failed: %s", CUstrerror(save_errno));
491 if (save_errno == ETIMEDOUT)
492 debug_printf(" (timeout=%s)", readconf_printtime(ob->connect_timeout));
504 return smtp_sock_connect(sc->host, sc->host_af, port, sc->interface,
505 sc->tblock, ob->connect_timeout, early_data);
509 /*************************************************
510 * Flush outgoing command buffer *
511 *************************************************/
513 /* This function is called only from smtp_write_command() below. It flushes
514 the buffer of outgoing commands. There is more than one in the buffer only when
518 outblock the SMTP output block
519 mode further data expected, or plain
521 Returns: TRUE if OK, FALSE on error, with errno set
525 flush_buffer(smtp_outblock * outblock, int mode)
528 int n = outblock->ptr - outblock->buffer;
529 BOOL more = mode == SCMD_MORE;
530 client_conn_ctx * cctx;
532 HDEBUG(D_transport|D_acl) debug_printf_indent("cmd buf flush %d bytes%s\n", n,
533 more ? " (more expected)" : "");
535 if (!(cctx = outblock->cctx))
537 log_write(0, LOG_MAIN|LOG_PANIC, "null conn-context pointer");
543 if (cctx->tls_ctx) /*XXX have seen a null cctx here, rvfy sending QUIT, hence check above */
544 rc = tls_write(cctx->tls_ctx, outblock->buffer, n, more);
549 if (outblock->conn_args)
551 blob early_data = { .data = outblock->buffer, .len = n };
553 /* We ignore the more-flag if we're doing a connect with early-data, which
554 means we won't get BDAT+data. A pity, but wise due to the idempotency
555 requirement: TFO with data can, in rare cases, replay the data to the
558 if ( (cctx->sock = smtp_connect(outblock->conn_args, &early_data))
561 outblock->conn_args = NULL;
566 rc = send(cctx->sock, outblock->buffer, n,
574 #if defined(__linux__)
575 /* This is a workaround for a current linux kernel bug: as of
576 5.6.8-200.fc31.x86_64 small (<MSS) writes get delayed by about 200ms,
577 This is despite NODELAY being active.
578 https://bugzilla.redhat.com/show_bug.cgi?id=1803806 */
581 setsockopt(cctx->sock, IPPROTO_TCP, TCP_CORK, &off, sizeof(off));
588 HDEBUG(D_transport|D_acl) debug_printf_indent("send failed: %s\n", strerror(errno));
592 outblock->ptr = outblock->buffer;
593 outblock->cmd_count = 0;
599 /*************************************************
600 * Write SMTP command *
601 *************************************************/
603 /* The formatted command is left in big_buffer so that it can be reflected in
607 sx SMTP connection, contains buffer for pipelining, and socket
608 mode buffer, write-with-more-likely, write
609 format a format, starting with one of
610 of HELO, MAIL FROM, RCPT TO, DATA, ".", or QUIT.
611 If NULL, flush pipeline buffer only.
612 ... data for the format
614 Returns: 0 if command added to pipelining buffer, with nothing transmitted
615 +n if n commands transmitted (may still have buffered the new one)
616 -1 on error, with errno set
620 smtp_write_command(void * sx, int mode, const char *format, ...)
622 smtp_outblock * outblock = &((smtp_context *)sx)->outblock;
627 gstring gs = { .size = big_buffer_size, .ptr = 0, .s = big_buffer };
630 /* Use taint-unchecked routines for writing into big_buffer, trusting that
631 we'll never expand the results. Actually, the error-message use - leaving
632 the results in big_buffer for potential later use - is uncomfortably distant.
633 XXX Would be better to assume all smtp commands are short, use normal pool
634 alloc rather than big_buffer, and another global for the data-for-error. */
636 va_start(ap, format);
637 if (!string_vformat(&gs, SVFMT_TAINT_NOCHK, CS format, ap))
638 log_write(0, LOG_MAIN|LOG_PANIC_DIE, "overlong write_command in outgoing "
641 string_from_gstring(&gs);
643 if (gs.ptr > outblock->buffersize)
644 log_write(0, LOG_MAIN|LOG_PANIC_DIE, "overlong write_command in outgoing "
647 if (gs.ptr > outblock->buffersize - (outblock->ptr - outblock->buffer))
649 rc = outblock->cmd_count; /* flush resets */
650 if (!flush_buffer(outblock, SCMD_FLUSH)) return -1;
653 Ustrncpy(outblock->ptr, gs.s, gs.ptr);
654 outblock->ptr += gs.ptr;
655 outblock->cmd_count++;
656 gs.ptr -= 2; string_from_gstring(&gs); /* remove \r\n for error message */
658 /* We want to hide the actual data sent in AUTH transactions from reflections
659 and logs. While authenticating, a flag is set in the outblock to enable this.
660 The AUTH command itself gets any data flattened. Other lines are flattened
663 if (outblock->authenticating)
665 uschar *p = big_buffer;
666 if (Ustrncmp(big_buffer, "AUTH ", 5) == 0)
669 while (isspace(*p)) p++;
670 while (!isspace(*p)) p++;
671 while (isspace(*p)) p++;
673 while (*p) *p++ = '*';
676 HDEBUG(D_transport|D_acl|D_v) debug_printf_indent(" SMTP%c> %s\n",
677 mode == SCMD_BUFFER ? '|' : mode == SCMD_MORE ? '+' : '>',
681 if (mode != SCMD_BUFFER)
683 rc += outblock->cmd_count; /* flush resets */
684 if (!flush_buffer(outblock, mode)) return -1;
692 /*************************************************
693 * Read one line of SMTP response *
694 *************************************************/
696 /* This function reads one line of SMTP response from the server host. This may
697 not be a complete response - it could be just part of a multiline response. We
698 have to use a buffer for incoming packets, because when pipelining or using
699 LMTP, there may well be more than one response in a single packet. This
700 function is called only from the one that follows.
703 inblock the SMTP input block (contains holding buffer, socket, etc.)
704 buffer where to put the line
705 size space available for the line
706 timelimit deadline for reading the lime, seconds past epoch
708 Returns: length of a line that has been put in the buffer
709 -1 otherwise, with errno set, and inblock->ptr adjusted
713 read_response_line(smtp_inblock *inblock, uschar *buffer, int size, time_t timelimit)
716 uschar *ptr = inblock->ptr;
717 uschar *ptrend = inblock->ptrend;
718 client_conn_ctx * cctx = inblock->cctx;
720 /* Loop for reading multiple packets or reading another packet after emptying
721 a previously-read one. */
727 /* If there is data in the input buffer left over from last time, copy
728 characters from it until the end of a line, at which point we can return,
729 having removed any whitespace (which will include CR) at the end of the line.
730 The rules for SMTP say that lines end in CRLF, but there are have been cases
731 of hosts using just LF, and other MTAs are reported to handle this, so we
732 just look for LF. If we run out of characters before the end of a line,
733 carry on to read the next incoming packet. */
740 while (p > buffer && isspace(p[-1])) p--;
748 *p = 0; /* Leave malformed line for error message */
749 errno = ERRNO_SMTPFORMAT;
755 /* Need to read a new input packet. */
757 if((rc = ip_recv(cctx, inblock->buffer, inblock->buffersize, timelimit)) <= 0)
759 DEBUG(D_deliver|D_transport|D_acl|D_v)
760 debug_printf_indent(errno ? " SMTP(%s)<<\n" : " SMTP(closed)<<\n",
765 /* Another block of data has been successfully read. Set up the pointers
766 and let the loop continue. */
768 ptrend = inblock->ptrend = inblock->buffer + rc;
769 ptr = inblock->buffer;
770 DEBUG(D_transport|D_acl) debug_printf_indent("read response data: size=%d\n", rc);
773 /* Get here if there has been some kind of recv() error; errno is set, but we
774 ensure that the result buffer is empty before returning. */
776 inblock->ptr = inblock->ptrend = inblock->buffer;
785 /*************************************************
786 * Read SMTP response *
787 *************************************************/
789 /* This function reads an SMTP response with a timeout, and returns the
790 response in the given buffer, as a string. A multiline response will contain
791 newline characters between the lines. The function also analyzes the first
792 digit of the reply code and returns FALSE if it is not acceptable. FALSE is
793 also returned after a reading error. In this case buffer[0] will be zero, and
794 the error code will be in errno.
797 sx the SMTP connection (contains input block with holding buffer,
799 buffer where to put the response
800 size the size of the buffer
801 okdigit the expected first digit of the response
802 timeout the timeout to use, in seconds
804 Returns: TRUE if a valid, non-error response was received; else FALSE
806 /*XXX could move to smtp transport; no other users */
809 smtp_read_response(void * sx0, uschar * buffer, int size, int okdigit,
812 smtp_context * sx = sx0;
813 uschar * ptr = buffer;
815 time_t timelimit = time(NULL) + timeout;
817 errno = 0; /* Ensure errno starts out zero */
819 #ifndef DISABLE_PIPE_CONNECT
820 if (sx->pending_BANNER || sx->pending_EHLO)
823 if ((rc = smtp_reap_early_pipe(sx, &count)) != OK)
825 DEBUG(D_transport) debug_printf("failed reaping pipelined cmd responsess\n");
827 if (rc == DEFER) errno = ERRNO_TLSFAILURE;
833 /* This is a loop to read and concatenate the lines that make up a multi-line
838 if ((count = read_response_line(&sx->inblock, ptr, size, timelimit)) < 0)
841 HDEBUG(D_transport|D_acl|D_v)
842 debug_printf_indent(" %s %s\n", ptr == buffer ? "SMTP<<" : " ", ptr);
844 /* Check the format of the response: it must start with three digits; if
845 these are followed by a space or end of line, the response is complete. If
846 they are followed by '-' this is a multi-line response and we must look for
847 another line until the final line is reached. The only use made of multi-line
848 responses is to pass them back as error messages. We therefore just
849 concatenate them all within the buffer, which should be large enough to
850 accept any reasonable number of lines. */
856 (ptr[3] != '-' && ptr[3] != ' ' && ptr[3] != 0))
858 errno = ERRNO_SMTPFORMAT; /* format error */
862 /* If the line we have just read is a terminal line, line, we are done.
863 Otherwise more data has to be read. */
865 if (ptr[3] != '-') break;
867 /* Move the reading pointer upwards in the buffer and insert \n between the
868 components of a multiline response. Space is left for this by read_response_
877 tfo_out_check(sx->cctx.sock);
880 /* Return a value that depends on the SMTP return code. On some systems a
881 non-zero value of errno has been seen at this point, so ensure it is zero,
882 because the caller of this function looks at errno when FALSE is returned, to
883 distinguish between an unexpected return code and other errors such as
884 timeouts, lost connections, etc. */
887 return buffer[0] == okdigit;
890 /* End of smtp_out.c */