wp-config.php constants
Any field of a connection can be defined as a constant in wp-config.php instead of in the database. A field set by a constant:
- is never stored in the database,
- is locked in the admin screen, where it shows Set in wp-config.php.
Add the constants above the line /* That's all, stop editing! */.
Naming
Section titled “Naming”STACKO_MAIL_MAILER Mailer ID of the primary connectionSTACKO_MAIL_{MAILER}_{FIELD} A field of the primary connection
STACKO_MAIL_BACKUP_MAILER Mailer ID of the backup connectionSTACKO_MAIL_BACKUP_{MAILER}_{FIELD} A field of the backup connection{MAILER} is the mailer ID in upper case (hyphens become underscores). {FIELD} is the field key in UPPER_SNAKE_CASE, so apiKey becomes API_KEY and verifyPeer becomes VERIFY_PEER.
Field constants apply only to the mailer they name. A STACKO_MAIL_SMTP_* constant does nothing while the primary connection uses Brevo. If you don’t define STACKO_MAIL_MAILER, choose the mailer in Connections and the matching field constants are applied.
Only connection fields, the mailer and the encryption key can be set as constants. General settings such as the From address are set in the admin.
Mailer IDs
Section titled “Mailer IDs”| Mailer | ID |
|---|---|
| Brevo | brevo |
| SendGrid | sendgrid |
| Mailgun | mailgun |
| Postmark | postmark |
| Other SMTP | smtp |
| WordPress default | default |
Defining STACKO_MAIL_MAILER (or STACKO_MAIL_BACKUP_MAILER) fixes the mailer for that connection. It can’t be changed in the admin, and Swap primary and backup is disabled.
All constants
Section titled “All constants”Other SMTP (smtp)
Section titled “Other SMTP (smtp)”| Constant | Field | Values |
|---|---|---|
STACKO_MAIL_SMTP_HOST |
SMTP host | e.g. smtp.example.com |
STACKO_MAIL_SMTP_PORT |
Port | e.g. 587 |
STACKO_MAIL_SMTP_ENCRYPTION |
Encryption | tls, ssl or none |
STACKO_MAIL_SMTP_AUTH |
Use authentication | true / false |
STACKO_MAIL_SMTP_USERNAME |
Username | |
STACKO_MAIL_SMTP_PASSWORD |
Password (secret) | |
STACKO_MAIL_SMTP_AUTO_TLS |
Upgrade to TLS automatically | true / false |
STACKO_MAIL_SMTP_TIMEOUT |
Timeout in seconds | 3–60 |
STACKO_MAIL_SMTP_VERIFY_PEER |
Verify the server’s certificate | true / false |
Brevo (brevo)
Section titled “Brevo (brevo)”| Constant | Field |
|---|---|
STACKO_MAIL_BREVO_API_KEY |
API key (secret) |
SendGrid (sendgrid)
Section titled “SendGrid (sendgrid)”| Constant | Field | Values |
|---|---|---|
STACKO_MAIL_SENDGRID_API_KEY |
API key (secret) | |
STACKO_MAIL_SENDGRID_REGION |
Data region | global or eu |
Mailgun (mailgun)
Section titled “Mailgun (mailgun)”| Constant | Field | Values |
|---|---|---|
STACKO_MAIL_MAILGUN_API_KEY |
API key (secret) | |
STACKO_MAIL_MAILGUN_DOMAIN |
Sending domain | e.g. mg.example.com |
STACKO_MAIL_MAILGUN_REGION |
Region | us or eu |
Postmark (postmark)
Section titled “Postmark (postmark)”| Constant | Field | Values |
|---|---|---|
STACKO_MAIL_POSTMARK_API_KEY |
Server API token (secret) | |
STACKO_MAIL_POSTMARK_MESSAGE_STREAM |
Message stream | default outbound |
For the backup connection, add BACKUP_ after STACKO_MAIL_, for example STACKO_MAIL_BACKUP_SMTP_PASSWORD.
Examples
Section titled “Examples”API key only
Section titled “API key only”// Primary connection: Brevo, key kept out of the database.define( 'STACKO_MAIL_MAILER', 'brevo' );define( 'STACKO_MAIL_BREVO_API_KEY', 'xkeysib-...' );Full SMTP connection
Section titled “Full SMTP connection”define( 'STACKO_MAIL_MAILER', 'smtp' );define( 'STACKO_MAIL_SMTP_HOST', 'smtp.example.com' );define( 'STACKO_MAIL_SMTP_PORT', 587 );define( 'STACKO_MAIL_SMTP_ENCRYPTION', 'tls' );define( 'STACKO_MAIL_SMTP_AUTH', true );define( 'STACKO_MAIL_SMTP_USERNAME', 'wordpress@example.com' );define( 'STACKO_MAIL_SMTP_PASSWORD', '...' );Backup connection
Section titled “Backup connection”define( 'STACKO_MAIL_BACKUP_MAILER', 'postmark' );define( 'STACKO_MAIL_BACKUP_POSTMARK_API_KEY', '...' );A secret is only sent to a server defined next to it
Section titled “A secret is only sent to a server defined next to it”An SMTP password defined in wp-config.php is only used if STACKO_MAIL_SMTP_HOST, STACKO_MAIL_SMTP_PORT and STACKO_MAIL_SMTP_USERNAME are defined too. Otherwise an admin, who can’t read wp-config.php, could point the connection at another server and capture the password.
If the password constant is defined without them, it is ignored, and the Connections screen says so. The same rule applies to STACKO_MAIL_BACKUP_SMTP_*.
API keys for Brevo, SendGrid, Mailgun and Postmark are always sent to that provider’s own API host, so they don’t need this.
Saved (database) secrets follow the same idea: changing the SMTP host, port or username in the admin drops the saved password.
Encryption key
Section titled “Encryption key”define( 'STACKO_MAIL_ENCRYPTION_KEY', 'a-long-random-string' );Secrets stored in the database are encrypted. By default the key is derived from WordPress’ AUTH_KEY and SECURE_AUTH_SALT. If those change, for example after a migration or a security plugin resetting the salts, saved secrets can’t be decrypted. The site then stops sending until they are entered again (error code credentials_unreadable).
Defining STACKO_MAIL_ENCRYPTION_KEY keeps the key stable when the salts rotate. Use any long random string, and keep it the same across environments that share the database.
Tools → Site Health → Info → Stacko Mail shows which key source is in use (STACKO_MAIL_ENCRYPTION_KEY or WordPress salts).
Development only
Section titled “Development only”define( 'STACKO_MAIL_VITE_DEV', 'http://localhost:5173' );Loads the admin app from a running Vite dev server with hot reloading. Only for working on the plugin itself.