-
Notifications
You must be signed in to change notification settings - Fork 1
Description
I know it's possible to send mail this way, but I want to suggest making wp mail a new command.
wp eval "wp_mail( 'test@example.org', 'My subject', 'My body' );"
While having the wp mail send will be useful, I actually thing the other subcommands might have more value for many developers.
Proposed subcommands:
wp mail send <to> <subject> <body> [--format=<text|html>]: A clean wrapper forwp_mail()to easily dispatch messages from the CLI.wp mail test <to>: Sends a standard test message but temporarily forces PHPMailer's$phpmailer->SMTPDebugto output verbose connection logs to the terminal. This would be invaluable for debugging SMTP plugin configurations or server-level mail blocks.wp mail statusorwp mail config: Outputs a table showing the current mail configuration (e.g., whether a plugin is hooking intophpmailer_init, the default From address, and content type).
Describe alternatives you've considered
The current alternative is using wp eval 'wp_mail(...);', which works for simple sending but is messy for HTML/attachments and provides zero debugging feedback if the mail fails to send due to a configuration or SMTP error.
Additional context
Having this natively in WP-CLI would save significant time for developers troubleshooting deliverability issues, especially on headless setups or when verifying automated server deployments.
Example Code:
https://gist.github.com/bhubbard/6e35a4ea677207928cd53bfe6c75c857