# Storing credentials in wp-config

> Keep a connection's credentials out of the database with a BOOLEANSMTP_{DRIVER}_{KEY} constant in wp-config.php or your server environment.

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`.
:::

Don't define a constant as an empty string — BooleanSMTP treats a defined-but-empty constant as present,
and it overrides a value stored in the database.

See <DevLink path="/constants/">the full list of constants</DevLink> for every driver's field names and
the constants BooleanSMTP reads outside connection settings.

## Next steps

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