I have several SQL databases on different servers. I have used a script to set up Database mail.
EXECUTE msdb.dbo.sysmail_add_account_sp @account_name = 'Emailer' ,@description = 'Email out reports' ,@email_address = 'XXXXXXX@XXXXXXX.com.au' ,@display_name = 'SA' ,@username = 'XXXXXXX@XXXXXXX.com.au' ,@password = '**********' ,@mailserver_name = 'smtp.office365.com' ,@replyto_address = 'XXXXXXXX@XXXXXXXX.com.au' EXECUTE msdb.dbo.sysmail_add_profile_sp @Profile_name = 'Emailer' ,@description = 'Email out reports' EXECUTE msdb.dbo.sysmail_add_profileaccount_sp @profile_name = 'Emailer' ,@accoun t_name = 'Emailer' ,@sequence_number = 1; EXECUTE msdb.dbo.sysmail_add_principalprofile_sp @profile_name = 'Emailer' ,@principal_name = 'public' ,@is_default = 1; UPDATE msdb.dbo.sysmail_server SET enable_ssl = 1
This script works, and then once I've run the script I try and send an email using Database Mail. On one server the email works, on another server I get the error:
The mail could not be sent to the recipients because of he mail server failure. (Sending Mail using Account 1 (2015-08-21T11:27:55). Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticaed to send anonymous mail during MAIL FROM).)
What could be causing this?