---
title: "Storing credentials in wp-config"
description: "Keep a connection's credentials out of the database with a BOOLEANSMTP_{DRIVER}_{KEY} constant in wp-config.php or your server environment."
image: "https://booleansmtp.com/docs/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://booleansmtp.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Storing credentials in wp-config

import DevLink from '@/components/DevLink.astro';

Every credential field a connection has can also be set from `wp-config.php` or your server's
environment instead of the database. A defined, non-empty constant always overrides the value stored
for that field.

## The naming rule

```
BOOLEANSMTP_{DRIVER}_{KEY}
```

— the connection's driver, then the field's key, both upper case.

## Example: Custom SMTP

A Custom SMTP connection's **SMTP Username** and **Password** fields are `username` and `password`, so
setting these in `wp-config.php` overrides them for every Custom SMTP connection on the site:

```php
define('BOOLEANSMTP_SMTP_USERNAME', 'your-smtp-username');
define('BOOLEANSMTP_SMTP_PASSWORD', 'your-smtp-password');
```

On the connection form, choose **Credential Storage: WP Config** to read the constant from
`wp-config.php`, or **Environment** to read it as an OS environment variable instead — either way, leave
the field itself blank.

:::note
This is a site-owner task: add the line to `wp-config.php` yourself, or hand it to whoever manages your
server. BooleanSMTP never writes to `wp-config.php`.
:::

Use a non-empty value. An empty constant or environment value does not replace a credential stored in the database;
if there is no stored credential, the connection still needs one.

See the full list of constants for every driver's field names and
the constants BooleanSMTP reads outside connection settings.

## Next steps

- [Custom SMTP](/docs/mailers/smtp/)
- [Amazon SES](/docs/mailers/ses/)
- [How a connection is chosen](/docs/advanced/how-a-connection-is-chosen/)

Source: https://booleansmtp.com/docs/advanced/wp-config-credentials/index.mdx
