---
title: "Get-DbaDbMailConfig"
description: "Retrieves Database Mail configuration settings from SQL Server instances"
url: "https://dbatools.io/Get-DbaDbMailConfig/"
availability: "Windows, Linux, macOS"
tags: ["Mail", "DbMail", "Email"]
author: "Chrissy LeMaire (@cl), netnerds.net"
source: "https://github.com/dataplat/dbatools/blob/master/public/Get-DbaDbMailConfig.ps1"
last_updated: "2024-01-01"
---

# Get-DbaDbMailConfig

## Synopsis

Retrieves Database Mail configuration settings from SQL Server instances

## Description

Retrieves all Database Mail configuration values from SQL Server, including settings like MaxFileSize, ProhibitedExtensions, DatabaseMailExeMinLifeTime, and LoggingLevel.  
This function helps DBAs audit current Database Mail configurations, troubleshoot email delivery issues, and verify compliance with organizational email policies.  
You can retrieve all configuration settings or filter by specific configuration names to focus on particular settings.  
The output includes the configuration name, current value, and description for each setting across your SQL Server environment.

## Syntax

```powershell
Get-DbaDbMailConfig
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-Name] <String[]>]
    [[-InputObject] <SqlMail[]>]
    [-EnableException]
    [<CommonParameters>]

```

## Examples

### Example 1: Returns DBMail configs on sql01\sharepoint

```powershell
PS C:\> Get-DbaDbMailConfig -SqlInstance sql01\sharepoint
```

### Example 2: Returns the ProhibitedExtensions configuration on sql01\sharepoint

```powershell
PS C:\> Get-DbaDbMailConfig -SqlInstance sql01\sharepoint -Name ProhibitedExtensions
```

### Example 3: Returns the DBMail configs on sql01\sharepoint then return a bunch more columns

```powershell
PS C:\> Get-DbaDbMailConfig -SqlInstance sql01\sharepoint | Select-Object *
```

### Example 4: Returns the DBMail configs for &quot;sql2014&quot;,&quot;sql2016&quot; and &quot;sqlcluster\sharepoint&quot;

```powershell
PS C:\> $servers = "sql2014","sql2016", "sqlcluster\sharepoint"
PS C:\> $servers | Get-DbaDbMail | Get-DbaDbMailConfig
```

### Optional Parameters

##### -SqlInstance

The target SQL Server instance or instances.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).  
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.  
For MFA support, please use Connect-DbaInstance.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Name

Specifies which Database Mail configuration settings to retrieve by name, such as MaxFileSize, ProhibitedExtensions, or LoggingLevel.  
Use this when you need to check specific configuration values instead of retrieving all Database Mail settings.  
Accepts multiple configuration names and supports aliases Config and ConfigName.

| Property | Value |
| --- | --- |
| Alias | Config,ConfigName |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -InputObject

Accepts Database Mail objects from Get-DbaDbMail for pipeline processing.  
Use this when chaining multiple Database Mail functions together or when you already have Database Mail objects loaded.  
Allows you to retrieve configurations from multiple SQL Server instances efficiently through the pipeline.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | true (ByValue) |
| Default Value |  |

##### -EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.  
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.  
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

## Outputs

**Microsoft.SqlServer.Management.Smo.Mail.ConfigurationValue**

Returns one Database Mail configuration setting per object with added properties from the parent SqlMail object.

**Default display properties (via Select-DefaultView):**

- ComputerName: The computer name of the SQL Server instance
- InstanceName: The SQL Server instance name
- SqlInstance: The full SQL Server instance name (computer\instance)
- Name: The configuration setting name (e.g., MaxFileSize, ProhibitedExtensions, DatabaseMailExeMinLifeTime, LoggingLevel)
- Value: The current value of the configuration setting
- Description: Human-readable description of what the configuration setting controls

**Additional properties available (from SMO ConfigurationValue object):**

- Parent: Reference to the parent SqlMail object
- Urn: The uniform resource name for the configuration value object
- Properties: Collection of SQL Server object properties
- State: The current state of the object (Existing, Creating, Pending, etc.)
All properties from the base SMO ConfigurationValue object are accessible using Select-Object * even though only default properties are displayed by default.

---

Part of [dbatools](https://dbatools.io/), a free and open source PowerShell module for SQL Server administration. Full command index: https://dbatools.io/commands/
