How to Check the Configuration Settings for Database Mail in SQL Server (T-SQL)

If you’re using Database Mail in SQL Server, you’ll probably want to check your configuration settings at some stage.

You can do this by executing the sysmail_help_configure_sp stored procedure in the msdb database.

Return All Configuration Settings

Executing the procedure without passing any arguments returns all configuration settings.

EXEC msdb.dbo.sysmail_help_configure_sp;

Result:

+--------------------------------+----------------+------------------------------------------------------------------------------
| paramname                      | paramvalue     | description                                                                  
|--------------------------------+----------------+------------------------------------------------------------------------------
| AccountRetryAttempts           | 1              | Number of retry attempts for a mail server                                   
| AccountRetryDelay              | 60             | Delay between each retry attempt to mail server                              
| DatabaseMailExeMinimumLifeTime | 600            | Minimum process lifetime in seconds                                          
| DefaultAttachmentEncoding      | MIME           | Default attachment encoding                                                  
| LoggingLevel                   | 2              | Database Mail logging level: normal - 1, extended - 2 (default), verbose - 3 
| MaxFileSize                    | 1000000        | Default maximum file size                                                    
| ProhibitedExtensions           | exe,dll,vbs,js | Extensions not allowed in outgoing mails                                     
+--------------------------------+----------------+------------------------------------------------------------------------------

Note that the sysmail_help_configure_sp stored procedure is in the msdb database and it is owned by the dbo schema. Therefore, the procedure must be invoked with a three-part name if msdb is not the current database.

Return a Specific Configuration Setting

If you only want to return one configuration setting, you can pass that to the stored procedure using the @parameter_name argument.

EXEC msdb.dbo.sysmail_help_configure_sp
    @parameter_name = MaxFileSize;

Result:

+-------------+--------------+---------------------------+
| paramname   | paramvalue   | description               |
|-------------+--------------+---------------------------|
| MaxFileSize | 1000000      | Default maximum file size |
+-------------+--------------+---------------------------+

Change the Configuration Settings

You can change the configuration settings with the sysmail_configure_sp stored procedure.