+ {
+ uschar * main_address = addr->address;
+
+ /*XXX oops, affixes */
+ addr->address = string_sprintf("postmaster@%.1000s", addr->domain);
+ addr->transport_return = PENDING_DEFER;
+
+ sx.from_addr = pm_mailfrom;
+ sx.first_addr = sx.sync_addr = addr;
+ sx.ok = FALSE;
+ sx.send_rset = TRUE;
+ sx.completed_addr = FALSE;
+ sx.avoid_option = OPTION_SIZE;
+
+ if( smtp_write_mail_and_rcpt_cmds(&sx, &yield) == 0
+ && addr->transport_return == PENDING_OK
+ )
+ done = TRUE;
+ else
+ done = (options & vopt_callout_fullpm) != 0
+ && smtp_write_command(&sx, SCMD_FLUSH,
+ "RCPT TO:<postmaster>\r\n") >= 0
+ && smtp_read_response(&sx, sx.buffer,
+ sizeof(sx.buffer), '2', callout);
+
+ /* Sort out the cache record */
+
+ new_domain_record.postmaster_stamp = time(NULL);
+
+ if (done)
+ new_domain_record.postmaster_result = ccache_accept;
+ else if (errno == 0 && sx.buffer[0] == '5')
+ {
+ *failure_ptr = US"postmaster";
+ setflag(addr, af_verify_pmfail);
+ new_domain_record.postmaster_result = ccache_reject;
+ }
+
+ addr->address = main_address;
+ }
+ }
+ /* For any failure of the main check, other than a negative response, we just
+ close the connection and carry on. We can identify a negative response by the
+ fact that errno is zero. For I/O errors it will be non-zero
+
+ Set up different error texts for logging and for sending back to the caller
+ as an SMTP response. Log in all cases, using a one-line format. For sender
+ callouts, give a full response to the caller, but for recipient callouts,
+ don't give the IP address because this may be an internal host whose identity
+ is not to be widely broadcast. */
+
+no_conn:
+ switch(errno)
+ {
+ case ETIMEDOUT:
+ HDEBUG(D_verify) debug_printf("SMTP timeout\n");
+ sx.send_quit = FALSE;
+ break;
+
+#ifdef SUPPORT_I18N
+ case ERRNO_UTF8_FWD:
+ {
+ extern int acl_where; /* src/acl.c */
+ errno = 0;
+ addr->message = string_sprintf(
+ "response to \"EHLO\" did not include SMTPUTF8");
+ addr->user_message = acl_where == ACL_WHERE_RCPT
+ ? US"533 no support for internationalised mailbox name"
+ : US"550 mailbox unavailable";
+ yield = FAIL;
+ done = TRUE;
+ }
+ break;
+#endif
+#if defined(SUPPORT_TLS) && defined(EXPERIMENTAL_REQUIRETLS)
+ case ERRNO_REQUIRETLS:
+ addr->user_message = US"530 5.7.4 REQUIRETLS support required";
+ yield = FAIL;
+ done = TRUE;
+ break;
+#endif
+ case ECONNREFUSED:
+ sx.send_quit = FALSE;
+ break;
+
+ case 0:
+ if (*sx.buffer == 0) Ustrcpy(sx.buffer, US"connection dropped");
+
+ /*XXX test here is ugly; seem to have a split of responsibility for
+ building this message. Need to rationalise. Where is it done
+ before here, and when not?
+ Not == 5xx resp to MAIL on main-verify
+ */
+ if (!addr->message) addr->message =
+ string_sprintf("response to \"%s\" was: %s",
+ big_buffer, string_printing(sx.buffer));
+
+ addr->user_message = options & vopt_is_recipient
+ ? string_sprintf("Callout verification failed:\n%s", sx.buffer)
+ : string_sprintf("Called: %s\nSent: %s\nResponse: %s",
+ host->address, big_buffer, sx.buffer);
+
+ /* Hard rejection ends the process */
+
+ if (sx.buffer[0] == '5') /* Address rejected */
+ {
+ yield = FAIL;
+ done = TRUE;
+ }
+ break;
+ }
+
+ /* End the SMTP conversation and close the connection. */
+
+ /* Cutthrough - on a successful connect and recipient-verify with
+ use-sender and we are 1st rcpt and have no cutthrough conn so far
+ here is where we want to leave the conn open. Ditto for a lazy-close
+ verify. */
+
+ if (cutthrough.delivery)
+ {
+ if (addr->transport->filter_command)