I am trying to set up email from my SQL Server 2014 installation. As I have the Express Edition, I do not have the Database mail wizard, but I seem to have all the stored procedures in the msdb database.

The error message is: The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account X (date). Exception Message: Cannot send mails to mail server. (Failure sending mail.).

It seems to me that the error indicates a problem with the email connection, rather than SQL Server, so I tried to send from a different email address – but with the same error. Both of these outgoing email addresses work reliably for my normal work (using Thunderbird). The set-up data was copied from Thunderbird.

I have used the set-up SQL from https://www.codeproject.com/articles/485124/configuring-database-mail-in-sql-server

-- Enable service broker in the MSDB database.
USE [master]

--Enabling Database Mail
sp_configure 'show advanced options',1

-- Enable the db mail feature at server level
sp_configure 'Database Mail XPs',1

--Creating a Profile
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'SQLProfile',
@description = 'Mail Service for SQL Server' ;

-- Create a Mail account 
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'SQL_Email_Account',
@email_address = '[email protected]',
@mailserver_name = 'smtp.googlemail.com',
@username='[email protected]',
@password='Emailid password'

-- Adding the account to the profile
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'SQLProfile',
@account_name = 'SQL_Email_Account',
@sequence_number =1 ;

-- Granting access to the profile to the DatabaseMailUserRole of MSDB
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'SQLProfile',
@principal_id = 0,
@is_default = 1;

The above is not intended to be run as a single script; each step was performed separately and each step worked.

Email was tested with:

--Sending Test Mail
-- See https://msdn.microsoft.com/en-us/library/ms190307.aspx for all arguments
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'SQLProfile',
@recipients = '[email protected]',
@body = 'Database Mail Testing',
@subject = 'Database Mail from SQL Server';

select * from msdb.dbo.sysmail_event_log

Then try a different email address:

USE [master]

-- Create a Database Mail account 2
EXEC msdb.dbo.sysmail_add_account_sp
@account_name = 'SQL_Email_Account 2',
@description = 'Alternative Mail account',
@email_address = '[email protected]',
@display_name = 'Alternate GMX',
@username='[email protected]',
@mailserver_name = 'mail.gmx.com';

-- Add the account 2 to the profile
EXEC msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'SQLProfile',
@account_name = 'SQL_Email_Account 2',
@sequence_number = 2 ;

-- Make one not the default
EXECUTE msdb.dbo.sysmail_update_principalprofile_sp
@profile_name = 'SQLProfile',
@principal_name = 'public',
@is_default = 0 ;

-- Show the new default profile
EXEC msdb.dbo.sysmail_help_principalprofile_sp

But this also failed with the same error. There are no messages in the SQL Server logs nor my firewall log.

I have tried some diagnostics that web searches have suggested:

Use msdb

select * from sysmail_profile
select * from sysmail_account
select * from sysmail_profileaccount where profile_id=1
select * from sysmail_server
EXEC msdb.dbo.sysmail_help_account_sp;
EXEC msdb.dbo.sysmail_help_profileaccount_sp @profile_name = 'SQLProfile';
EXEC msdb.sys.sp_helprolemember 'DatabaseMailUserRole';
EXEC msdb.dbo.sysmail_help_principalprofile_sp;
EXEC msdb.dbo.sysmail_help_status_sp;
exec [dbo].[sysmail_configure_sp] 'LoggingLevel', 3

All the return values are normal, so I’ve not posted a duplicate of the set-up data. My only problem is that setting LoggingLevel to verbose does not seem to have any effect – is that data stored elsewhere that I have not looked?

Any hints would be appreciated, either to fix the problem or for more diagnostics. Thank you.

3 Answers 3


Sorry but SQL Server Express does not support database mail (check the "Additional Database Services" section):



Mail Service is a Additional Database Services, which is Microsoft only Providing this services along with the SQL Server of version like :

  1. Enterprise
  2. Business Intelligence
  3. Standard
  4. Web

You shall not get mail services feature along with this edition of SQL Server version like :

  1. Express with Advanced Services
  2. Express with Tools
  3. Express

For Your Further Ref Features Supported by the Editions of SQL Server 2014


You have some config issue with that specific email account. While MS SQL Express does not suport DB mail with the GUI, it is possible to send mails having setup with the stored procedures - I have done so recently with gmail and an app password following the procedures in https://www.sqlshack.com/database-mail-configuration-in-sql-server-express-edition/ for the dbmail side and following https://learn.microsoft.com/en-us/answers/questions/882492/how-to-send-sql-server-database-mail-through-gmail

  • Hi Adrian, links can disappear. Its preferable to post the essential points here, as well as the links. Commented Sep 29, 2023 at 10:43
  • Adrian, thanks for your answer, but I have moved on. This project has been dead for a long time.
    – Peter Bill
    Commented Sep 30, 2023 at 10:12

Your Answer

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

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