0

We migrated 4 servers with SQL Server instances to Azure VM around 2-3 months ago. We configured "database mail" the same way we did for the on-prem servers. Mail worked fine immediately. All of a sudden, yesterday around 4 pm, mails were not able to be sent.

Error is: The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2020-02-06T08:20:42). Exception Message: Could not connect to mail server. (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond :25).)

We have researched and all we find is that we should not use port 25, but when we change it to port 587 it failed as well.

The settings we use to configure database mail account are:

  • Server name: .mail.protection.outlook.com
  • Port: 25
  • SMTP Authentication: Anonymous.

By the way, the servers we still have on-premises are working fine using the exact same settings.

As a workaround, we have configured sendgrid to send mail for the azure servers, but my question is if someone can help us to configure the SQL Server database mail correctly in the azure vm using the office 365 exchange.

Thanks!

2

Check out this link - basically, you need to use an authenticated relay (like sendgrid) when sending from an Azure VM.

There are some exceptions:

  • Enterprise Agreement subscriptions don't have this restriction
  • Pay-As-You-Go subscriptions can submit an exemption request and if approved you will not have to use an authenticated relay. Note, this only applies to VMs. PaaS services cannot be exempted.

All other subscriptions do not have the exemption option - you must use an authenticated relay.

1
  • Thanks for your answer. We have office 365 exchange service, in our on-premises servers we use it as anonymous authentication but we could use it as authenticated, the issue is that if we use those same settings (add SSL check and basic authentication) for the azure vms, it doesn’t work. For the on-premises servers it works. Do you know if it’s possible to use office 365 exchange service to achieve this goal? Thanks again. Feb 7 '20 at 7:45
1

After trying more combinations, we have found the correct set of parameters we need to use when configuring database mail in Azure VM:

Outgoing mail Server

-E-Mail address: the same mail that will be used to authenticate the connection.

-Server name: smtp.office365.com

-Port Number: 587

-Check the box: This server requires a secure connection SSL

SMTP Authentication:

-Basic authentication: The user name should be in the form of an e-mail address. Very Important: the e-mail address used here should be the same as the e-mail address used above (Outgoing mail server).

I hope this helps for the people using SQL Server in Azure VMs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.