0

I have been trying to send an email to my outlook account using SQL server management studio but keep facing with error like: The smtp server requires a secure connection or the client was not authenticated 5.7.57; client was not authenticated to send anonymous mail during MAIL FROM [__.prod.outlook.com] even though I have ensured that everything was inputted correctly.

Here's the query:

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO

sp_configure 'Database Mail XPs', 1;
GO
RECONFIGURE
GO

EXECUTE msdb.dbo.sysmail_add_profile_sp  
    @profile_name = 'Test_Email',  
    @description = 'Profile used for sending outgoing notifications using Outlook.' ;  
GO


EXECUTE msdb.dbo.sysmail_add_principalprofile_sp  
    @profile_name = 'Test_Email',  
    @principal_name = 'public',  
    @is_default = 1 ;
GO

EXECUTE msdb.dbo.sysmail_add_account_sp  
    @account_name = 'Outlook',  
    @description = 'Mail account for sending outgoing notifications.',  
    @email_address = '[email protected]',  
    @display_name = 'Automated Mailer',  
    @mailserver_name = 'smtp.office365.com',
    @port = 587,
    @enable_ssl = 1,
    @username = '[email protected]',
    @password = 'password' ;  
GO

-- Add the account to the profile  
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp  
    @profile_name = 'Test_Email',  
    @account_name = 'Outlook',  
    @sequence_number =1 ;  
GO

EXEC msdb.dbo.sp_send_dbmail
     @profile_name = 'Test_Email',
     @recipients = '[email protected]',
     @body = 'The database mail configuration was completed successfully.',
     @subject = 'Automated Success Message';
GO

sp_configure 'show advanced', 1; 
GO
RECONFIGURE;
GO
sp_configure;
GO


SELECT * FROM msdb.dbo.sysmail_event_log;

Can anyone advise what went wrong?

Thank you in advance!

Edited: Added @ to email addresses!

4
  • Does the password have any special characters? Apr 20, 2020 at 4:26
  • I don't see any @ characters in your e-mail addresses. Have you tried using correct e-mail addresses? Welcome to DBA.SE.
    – John K. N.
    Apr 20, 2020 at 5:31
  • @Johnakahot2use Hi! I have @ in my email addresses. Sorry for the confusion that I missed out when I was replacing them. Will add them in to prevent confusion.
    – user207025
    Apr 20, 2020 at 5:35
  • @RandolphWest Hi, yes! it has an exclamation mark, does it have an effect?
    – user207025
    Apr 20, 2020 at 5:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.