SQL Server 2016 Database Mail Not Working

One of the nice things about SQL Server 2016 is that .NET 3.5 is no longer required for installation. The .NET requirement wouldn’t have been problematic, but in order to add the .NET feature access to the Windows media was required (this was particularly painful in Azure VMs). Fortunately the product team eliminated the requirement as part of the release. Unfortunately, a few things broke–namely database mail, native log shipping, and distributed replay. You can identify this problem, by a couple of symptoms:

  • Your database mail log has no entries
  • You have messages with a status of “unsent’ in sysmail_allitems in MSDB

Screen Shot 2016-07-27 at 2.41.59 PM

  • If you try to execute the file C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn\DatabaseMail.exe you get a .NET 3.5 error

This should be fixed in CU2, but there are reports below of it failing in SP1. The XML to put in the .config files is:

<?xml version=1.0 encoding=utf-8 ?>

<configuration>

  <startup useLegacyV2RuntimeActivationPolicy=true>

    <supportedRuntime version=v4.0/>

    <supportedRuntime version=v2.0.50727/>

  startup>

configuration>

About jdanton1
A DBA, cyclist, cook (who likes to play chef occasionally)

22 Responses to SQL Server 2016 Database Mail Not Working

  1. Vladislav says:

    Hi Joey, there is already a ‘Cumulative Update 2 for SQL Server 2016’ (https://support.microsoft.com/en-us/kb/3182270) with ‘FIX: SQL Server 2016 Database Mail does not work on a computer that does not have the .NET Framework 3.5 installed’ (https://support.microsoft.com/en-us/kb/3186435).

  2. shatter_h says:

    if you don’t want to use Database Mail or you have SQL Express, try vsql-email, just search on google.

  3. Eric says:

    Joey D’Antoni, you’re a genius. Thank you! Helped me solve my issue with SQL Server 2016 RTM.

  4. Emerson says:

    Hmmm, I’ve got exactly the symptoms detailed here, but on 2016 Ent Ed *SP1* (Microsoft SQL Server 2016 (SP1-GDR) (KB3207512) – 13.0.4199.0)

    So the fix in the CU seems to have been regressed?

    Unfortunately the workaround (copying the log shipping config file) isn’t working for me however.

    Anyone else seeing this, please?

    • jdanton1 says:

      I tried to repro and could not. I did a new install of SP1 on Windows 2016 and mail just worked.

      • Steve Buchanan says:

        I agree with Emerson – I’m SQL 2016 Std SP1 (Microsoft SQL Server 2016 (SP1-GDR) (KB3207512) – 13.0.4199.0 (X64)) and mail’s not sending. It was prior to SP1 installation as had previously installed CU2… Is Microsoft addressing?

      • jdanton1 says:

        Hmm..I tried to repro again. I installed SQL 2016 RTM, it didn’t work, I installed SP2, database mail worked, and then I installed SP1, and it still worked. I did use Enterprise Edition, but I still can’t think of a reason why this would matter. Just out of curiosity what OS are you on?

    • RAThor says:

      Agreed. I have stuck email on SQL Server 2016 (SP1-CU1) (KB3208177) – 13.0.4411.0 (X64) , Windows Server 2012 R2 Standard 6.3

  5. Steve Buchanan says:

    Windows 2012 R2 with all latest updates applied. I gave in this afternoon, battled for several days, and installed .Net 3.5. Bugger but needed this working in a production enviro.
    Cheers

  6. Kevin Farlee says:

    You can always replace the contents of the .config file with:

    I’ll have to look into what happened in SP1 to the .config files.

    Kevin Farlee
    SQL Server team

    • Kevin Farlee says:

      Looks like the blog stripped out the XML. Let’s see if this works:
      .
      .
      .
      .   
      .
      .
      .

      You’ll have to delete the “.” at the start of each line.

      • Judy Way says:

        I’m not seeing anything in your post other than the “.” Can you resend? I’m having this same issue on a SQL 2016.1 Standard server.

  7. RAThor says:

    Which config file(s)?

  8. jdanton1 says:

    C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn\DatabaseMail.exe.config

    • Mitch says:

      Thank you for the info!

      FYI I just spent several frustrating hours on this and finally landed here after checking all the usual suspects.

      Our SP1-CU2 machine gave the .NET 3.5 message when double-clicking on DatabaseMail.exe. Further, there was no associated DatabaseMail.exe.config file.

      However, I grabbed the config from another SQL 2016 instance (pure SP1 no CU) on which mail *is* working and used that. For reference, here are the XML contents. Tags are replaced with + signs in an attempt to avoid having the XML stripped out of the post.

      +?xml version=”1.0″ encoding=”utf-8″ ?+
      +configuration+
      +startup useLegacyV2RuntimeActivationPolicy=”true”+
      +supportedRuntime version=”v4.0″/+
      +supportedRuntime version=”v2.0.50727″/+
      +/startup+
      +/configuration+

  9. Emerson says:

    Hi,

    Sorry I didn’t get back sooner about OS, Joey. And thanks for trying to repro!

    Some good news for me – and hopefully for others!

    After installing CU1 for SP1, it was still broken. BUT I then found if I created a DatabaseMail.exe.config in the *same folder* as DatabaseMail.exe, this fixed it. Either a copy of SqlLogShip.exe.config, or slightly different XML as per https://www.reddit.com/r/SQLServer/comments/4rd5kg/sql_server_2016_database_mail_and_net_35_framework/, is working for me.

    OS is Server 2012 R2, BTW. My install is under D:\, not C:\ – just in case that’s part of the issue
    (surely not!) 😮

  10. Emerson says:

    P.S. for anyone on various fora saying “just install .NET3.5”, it’s not only that you need OS media – you then need to apply at least 22 critical/security updates (on 2012 R2 anyway), plus reboot…

  11. jetnag says:

    I think I love you. We are on RTM and the .config file workaround worked.
    We will patch to SP1-CU2 and see if the issue is fixed there.
    Thanks!

  12. charlie says:

    Superb! The missing config file was the culprit. This saved hours of time as we were completely baffled.

  13. Mayur Khare says:

    This was an awesome hint!! We faced this issue in production today while setting up new servers and had already spent several hours before I came across this post. We created a config file where it was missing and boom – DBMail worked!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: