* Exim - an Internet mail transport agent *
*************************************************/
+/* Copyright (c) The Exim Maintainers 2021 - 2022 */
/* Copyright (c) Jeremy Harris 2020 */
-/* Copyright (c) The Exim Maintainers 2021 */
/* See the file NOTICE for conditions of use and distribution. */
+/* SPDX-License-Identifier: GPL-2.0-only */
#include "../exim.h"
#include "lf_functions.h"
#ifndef DISABLE_TLS
if (do_tls)
{
+ 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};
+ 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;
+ }
+
if (!tls_client_start(cctx, &conn_args, NULL, &tls_dummy, &errstr))
{
*errmsg = string_sprintf("TLS connect failed: %s", errstr);