2

I am getting an error in SQL Server 2012 Database Mail when executing a stored proc to send an email from a specified address to a specified address using Office 365 as the SMTP server.

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2014-06-10T15:28:48). Exception Message: Cannot send mails to mail server. (Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as this sender).

This same stored proc is working in production on another server fine. The only change is that this instance of the working stored proc is SQL Server 2008 R2.

Judging from the error this is a SMTP error, am I correct? All users I am using to send and receive the mail are in the same O365 domain and have {SendAs} access rights and NT Authority\Self Trustees in O365.

I can telnet office 365 over the specified port (587) fine and even stranger is I can send email using the 'Send Test E-Mail' feature in DB Mail fine using the same Office 365 profile that is specified in the stored proc.

Any help would be appreciated.

Screenshot of database mail settingsenter image description here

medina
  • 135
  • 1
  • 3
  • 11
  • Could you post your SQL Server SMTP Relay configuration (obfuscate what is sensitive)? –  Jun 13 '14 at 13:37
  • @SujaySarma screenshot in edit of post – medina Jun 13 '14 at 13:53
  • Are you able to logon as this (noreply@....com) user in the Outlook Web Access for your O365 account and send out email? –  Jun 13 '14 at 13:56
  • @SujaySarma Yes. This email address is working with identical configs in SQL Server 2008 R2 on another server. I can even send a test email in database mail using the profile in the screenshot. However I get a 5.7.1 error when I execute the query to send email using this db mail profile. – medina Jun 13 '14 at 14:00
  • Are you sure this is the only account on the server? – mrdenny Jun 18 '14 at 17:40
  • @mrdenny yes this is the only account and profile on the server. – medina Jun 23 '14 at 08:22

1 Answers1

0

To fix this issue I have installed a SMTP server locally on the same server as the SQL Server instance. I configured DB mail to localhost then set the Office 365 settings in the SMTP server ensuring that TLs encryption and the correct port is stated.

This seemed to fix the issue for me.

medina
  • 135
  • 1
  • 3
  • 11