SQL Server 2016 Database Mail Not Working

Spread the love

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>

27 thoughts on “SQL Server 2016 Database Mail Not Working

  1. shatter_h

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

    Reply
  2. Emerson

    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?

    Reply
      1. Steve Buchanan

        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?

      2. jdanton1

        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?

    1. RAThor

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

      Reply
  3. Steve Buchanan

    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

    Reply
  4. Kevin Farlee

    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

    Reply
    1. Kevin Farlee

      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.

      Reply
      1. Judy Way

        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.

    1. Mitch

      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+

      Reply
      1. Oliver

        This worked perfectly for me. 2016 SP1 CU2 on Server 2012 R2.

        I had no DatabaseMail.exe.config file so manually created it and added the XML code above. Sent a test email via SSMS and it worked!

        Thanks,

  5. Emerson

    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!) 😮

    Reply
  6. Emerson

    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…

    Reply
  7. jetnag

    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!

    Reply
  8. charlie

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

    Reply
  9. Mayur Khare

    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!!

    Reply
  10. Mark Rovendro

    I copied and pasted the XML above and fixed the tags and it still didn’t work. Come to find out that my double quotes where back ticks and not quotes. Just wanted to mention this if somebody else ran into the same problem. I copied the config from a running system and found my issue.

    Reply
  11. Jagadeesh P

    Hi Team,

    I have installed SQL 2016 SP2, CU16 , still DB Mail is not working, from this blog I have added config file , still DB mail not working I have installed .Net 3.5 SP1 as well though it is not working, any inputs please
    OS Windows 10 server:

    DatabaseMail.exe.config:

    Is reboot or repair is mandatory..? please suggest

    Reply
  12. Pingback: SQL Server 2016 DB Mail Not Sending

  13. Pingback: SQL Server 2016 DB 메일이 전송되지 않음 규칙을 입력했습니다. 전송되지 - How IT

Leave a Reply to jdanton1Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.