concept-image / wp-smtp
SMTP for Acorn sites, configured from .env with per-environment profiles: Mailpit in development, Ethereal in staging (nothing sent without credentials), a real SMTP server in production (loud alerts when missing). Sender rules that keep plugin senders, debug logging without credentials, a dashboard
Requires
- php: >=8.3
- concept-image/wp-hook-attributes: ^0.1
- roots/acorn: ^6.4
Requires (Dev)
- brain/monkey: ^2.6
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0|^5.0
- pestphp/pest-plugin-arch: ^4.0|^5.0
- phpmailer/phpmailer: ^6.9
- szepeviktor/phpstan-wordpress: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Per-environment SMTP for WordPress sites on Acorn
Built for Bedrock + Roots Acorn 6.4. Every wp_mail() is sent over SMTP with settings read from
.env only, and each environment gets a safe default:
Environment (WP_ENV) | Profile | With empty variables |
|---|---|---|
development, local | Mailpit | mailpit:1025, no auth, no TLS |
staging | Ethereal | smtp.ethereal.email:587 STARTTLS with the project's account; nothing is sent without credentials |
production (and any other) | SMTP | no default: PHP mail() with a daily critical log, an admin notice and smtp:status exiting 1 |
An explicit SMTP_HOST always wins. There is no default credential anywhere.
Requirements
- PHP 8.3+
- Roots Acorn 6.4+
concept-image/wp-hook-attributes^0.1 (installed with the package)
Installation
composer require concept-image/wp-smtp
Themes on concept-image/wp-starter-theme already have it.
Configuration
All settings live in the Bedrock .env:
| Variable | Default | |
|---|---|---|
SMTP_HOST | profile | SMTP server (2.x name SMTP_SERVER still read, deprecated) |
SMTP_PORT | from the encryption, else profile | integer |
SMTP_USERNAME / SMTP_PASSWORD | none | SMTP authentication only when the username is set |
SMTP_ENCRYPTION | from the port (465 ssl, 25/1025 none, else tls) | none, tls (STARTTLS) or ssl (2.x name SMTP_SECURE, deprecated) |
SMTP_FROM | WordPress default | sender address, validated |
SMTP_FROM_NAME | WordPress default | sender name (2.x name SMTP_NAME, deprecated) |
SMTP_FORCE_FROM | false | send every mail from SMTP_FROM |
SMTP_DEBUG | 0 | PHPMailer transcript level 1–4, written to the log with credentials redacted |
Development (written by igor):
SMTP_HOST=mailpit
SMTP_PORT=1025
Staging: create an account on ethereal.email, then
SMTP_USERNAME=jane.doe12@ethereal.email
SMTP_PASSWORD=the-generated-password
SMTP_FROM=contact@client-domain.fr
Production: the provider's host, port, credentials and a SMTP_FROM on a domain it may send for.
The theme can publish config/smtp.php (wp acorn vendor:publish --tag=wp-smtp-config) to map other environments
(environments), switch off the sender rules (sender) or the dashboard widget (widget).
Sender
SMTP_FROM / SMTP_FROM_NAME replace only WordPress' default sender ("WordPress" <wordpress@your-host>): a
plugin's sender, such as a Gravity Forms notification, is kept. With SMTP_FORCE_FROM=true every mail leaves from
SMTP_FROM and the original sender becomes the Reply-To. The envelope sender (Return-Path) always follows From.
Commands
wp acorn smtp:status # resolved settings, masked; exit 1 when this environment can't send (deploy check)
wp acorn smtp:test you@example.com # send a test mail through wp_mail(), print the error
Administrators also get an "E-mails (SMTP)" dashboard widget with the status and a test mail form.
Claude Code
wp acorn vendor:publish --tag=wp-smtp-ai publishes the wp-smtp skill and rules into the Bedrock root's
.claude/ (wp-starter-theme's wp acorn starter:ai does it for you).
Upgrading
From 2.x: see UPGRADE.
Changelog
Please refer to CHANGELOG for more information.
Contributing
Please refer to CONTRIBUTING for more information.
License
Please refer to LICENSE for more information.
Credits
- Banner icon: Paper plane icons created by Magnific - Flaticon