Search code examples
sql-servert-sqlsp-send-dbmaildatabase-mail

Change the server name in the HELO exchange in SQL Server Database Mail


When my SQL Database mail connects to my SMTP provider it shows the local server name rather than the FQDN. I would like to find the configuration setting so that the HELO exchange uses the FQDN. For example, the email header shows the following:

# Received: from XXXXXXXXXXSQLSVR (unknown)
    by geopod-ismtpd-8 (SG) with ESMTP
    id hd6Gp5D_QYKF9OEZESI-tA
    Thu, 07 Sep 2023 18:49:36.406 +0000 (UTC)

and I would like it to be:

**Received: from MailServer.XYZDomain.com (111.111.111.111)**
    by geopod-ismtpd-8 (SG) with ESMTP
    id hd6Gp5D_QYKF9OEZESI-tA
    Thu, 07 Sep 2023 18:49:36.406 +0000 (UTC)

I have not been able to find a config setting anywhere that controls that HELO value.

Thank you


Solution

  • I don't know if this is going to work, as I haven't tested it, but since DatabaseMail.exe is the application that actually sends the emails, and it uses SmtpClient apparently, you can try adding to the XML configuration file at DatabaseMail.exe.config. This is located in your SQL Server instance location, in a folder called Binn.

    <configuration>
      <system.net>
        <mailSettings>
          <smtp>
            <network clientDomain="MailServer.XYZDomain.com" />
          </smtp>
        </mailSettings>
      </system.net>
    </configuration>
    

    There will presumably already be a <configuration> node, so just merge it togther.

    More settings can be seen here in the docs, do note that the application will probably overwite most of them from its own config in the msdb database.

    Don't forget to restart the DBMail service after the changes.