使用smtp.office365.com时Database Mail 的一些额外设置

Standard
Basic Authentication
PORT = 587
Use SSL = True
Server Name = smtp.office365.com

TLS 1.2 is required.

    How to set up a multifunction device or application to send email using Microsoft 365 or Office 365 also says:

    Transport Layer Security (TLS): Your device must be able to use TLS version 1.2 and above.

    • DatabaseMail.exe is built for .NET Framework 3.5, but you need a .NET Framework installed that supports TLS 1.2 (.NET Framework 4.5.2 or later).
    • TLS 1.2 client protocol should be enabled at the machine level in Registry
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
    "DisabledByDefault"=dword:00000000
    "Enabled"=dword:00000001
    
    • TLS 1.2 client protocol should be enabled for .NET Framework 4.x in the Registry
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
    "SchUseStrongCrypto"=dword:00000001
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
    "SchUseStrongCrypto"=dword:00000001
    
    • An appropriate supportedRuntime should be in DatabaseMail.exe.config file, e.g.: with Microsoft .NET Framework 4.5.2 installed:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <add key="DatabaseServerName" value="." />
        <add key="DatabaseName" value="msdb" />
      </appSettings>
      <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
      </startup>
    </configuration>
    
    1. Via the Database Mail settings in SSMS, configure the sending account appropriately:
    • Server name: smtp.office365.com
    • Port number: 587 (preferred, or 25)
    • This server requires a secure connection (SSL): must be ticked (this enables STARTTLS)
    • SMTP Authentication:
      • Basic authentication (selected)
        • User name: sending_mailbox_user@your_domain.com
        • Password: your_office365_password
        • Confirm password: your_office365_password_again