- auth_defer_msg = US"authentication socket path too long";
- return DEFER;
- }
-
-auth_defer_msg = US"authentication socket connection error";
-
-if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
- return DEFER;
+ union sockaddr_46 interface_sock;
+ EXIM_SOCKLEN_T size = sizeof(interface_sock);
+ smtp_connect_args conn_args = { .host = &host };
+ tls_support tls_dummy = { .sni = NULL };
+ uschar * errstr;
+
+ if (getsockname(cctx->sock, (struct sockaddr *) &interface_sock, &size) == 0)
+ conn_args.sending_ip_address = host_ntoa(-1, &interface_sock, NULL, NULL);
+ else
+ {
+ *errmsg = string_sprintf("getsockname failed: %s", strerror(errno));
+ goto bad;
+ }