| 开发者 | cododigital |
|---|---|
| 更新时间 | 2026年10月23日 20:32 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
wp_mail() call through a proper email provider instead of your server's unauthenticated PHP mail.
It is built by Codo Digital, a UK web development and managed hosting company, and is the mailer we use on our own clients' sites. Everything is free. There is no Pro version, no upsell, no account to create and no tracking.
Providers
eu-west-2)wp_mail(). Core hooks such as wp_mail_from, wp_mail_content_type, wp_mail_succeeded and wp_mail_failed keep working. phpmailer_init (used by DKIM-signing plugins) runs for SMTP, Amazon SES and Mailgun, which send full MIME; Postmark, Brevo and SendGrid build the message on their side, so it does not run for them (see the FAQ).manage_options; on multisite, super admins only, because whoever controls mail can read any user's reset email). There are no REST or AJAX endpoints for it.wp-config.php constants.host, port, encryption (tls, ssl, none), auth, username, password; SES region, access_key, secret_key, session_token (optional, for temporary credentials); Postmark server_token, message_stream; Mailgun domain, api_key, region (eu, us); Brevo and SendGrid api_key.
If an SMTP password is a constant but the host, port, encryption or username are not, the first successful send locks the connection to that server. Changing any of them in the admin screen then stops the connection, so the password can't be redirected to another server. To move servers, set the new values as constants too.
To use your own encryption key instead of the site salts, define CODO_MAILER_ENCRYPTION_KEY. See "How do I set a strong encryption key?" in the FAQ. If you rotate your salts without one, re-enter saved API keys and passwords (secrets set as constants are unaffected).
For developers
codo_mailer_redaction_patterns filter: add regular expressions for other secrets (e.g. magic-login tokens). They apply to the subject as well as the body.codo_mailer_transport filter: provide a transport for a custom connection type.codo_mailer_alert_interval filter: change the alert throttle (seconds).codo_mailer_attachment_size_limit filter: change the largest total attachment size an API connection will send (bytes; 10 MB for Postmark, 25 MB otherwise, 0 for no cap). Larger emails fail on that connection and go to the backup.codo_mailer_smtp_allow_plaintext_auth filter: return false to refuse SMTP logins over an unencrypted connection (other than to localhost).codo_mailer_capability filter: change who can manage the plugin. Read "Can I let editors or shop managers manage email?" in the FAQ first.codo_mailer_message filter: change an email before it is sent, for every provider. It receives the CodoDigital\Mailer\Mail\Message and the source (wp_mail, test or resend) and must return a Message, e.g. $message->with( array( 'bcc' => array( array( 'email' => 'archive@example.com', 'name' => '' ) ) ) ). It runs once per email, before the primary connection; the backup, the log and wp_mail_succeeded see the result. Use it instead of phpmailer_init, which Postmark, Brevo and SendGrid never fire.codo_mailer_sent action: fires after delivery with the message, connection and provider result.codo-mailer folder to /wp-content/plugins/.Yes. Codo Mailer connects your site to a provider; it doesn't send email itself. Amazon SES, Postmark, Mailgun, Brevo and SendGrid all have free or low-cost tiers, or you can use your existing mailbox's SMTP server.
Yes. Anything that sends through wp_mail() goes through Codo Mailer.
Some plugins change outgoing email by hooking WordPress's phpmailer_init action, which hands them the PHPMailer object just before sending: to add a DKIM signature, Bcc archive copies, embedded images or extra headers. Codo Mailer fires it for SMTP, Amazon SES and Mailgun, which send a full MIME message built with PHPMailer. Postmark, Brevo and SendGrid take the email as JSON through their APIs, so there is no PHPMailer object and phpmailer_init does not run for them; those plugins' changes are skipped. The settings screen points this out when you pick one of these providers, and warns if a plugin on your site uses the hook.
What to do instead:
codo_mailer_message filter (see "For developers"), which runs for every provider.phpmailer_init keeps working.The reset link was redacted before logging, so the logged copy no longer contains it. Ask the user to request a new reset, which is also safer.
The failure is logged with each provider's error, WordPress's wp_mail_failed action fires, and an alert goes to your alert email and/or webhook.
No. It talks only to the email provider (and alert webhook) you configure.
Yes. Codo Mailer adds an exporter and an eraser to Tools > Export Personal Data and Tools > Erase Personal Data. Both find log entries where the person's address is a To, Cc, Bcc or Reply-To address (exact matches only, ignoring case).
For the number of days set in "Keep logs for (days)", 30 by default. Old entries are deleted by a daily WP-Cron task, which WordPress runs when the site gets visits. If your site sets DISABLE_WP_CRON, make sure a system cron job calls wp-cron.php (or runs wp cron event run --due-now), otherwise entries are kept until it does. You can also empty the log at any time with "Delete all log entries" on the Email log tab.
Yes. Each site has its own settings and log, managed by super admins only. Constants in wp-config.php apply to every site in the network.
Yes. Temporary credentials come with a session token, which Codo Mailer sends as X-Amz-Security-Token and includes in the request signature. You can supply them in three ways:
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN environment variables, as set on AWS Lambda and by many container platforms.CODO_MAILER_PRIMARY_SESSION_TOKEN (or CODO_MAILER_BACKUP_SESSION_TOKEN) in wp-config.php alongside the access key and secret, for example from values your deployment refreshes.Over SMTP, Amazon SES and Mailgun, yes. Postmark, Brevo and SendGrid require at least one To address and will report an error.
Each provider call times out after 15 seconds. Failure alerts are sent at the end of the request, after the page has been delivered where the server supports it, so visitors don't wait for them.
With Encryption set to None and Authenticate on, your SMTP username and password are sent to the server in plain text, where anyone on the network path can read them. Codo Mailer also turns off automatic STARTTLS in this mode, so this happens even if the server supports encryption. Choose TLS or SSL unless the server is a trusted relay on your own network. Connections to localhost are not warned about. Hosts can refuse plaintext logins outright with the codo_mailer_smtp_allow_plaintext_auth filter.
Saved API keys and passwords are encrypted with a key derived from WordPress's AUTH_KEY, AUTH_SALT, SECURE_AUTH_KEY and SECURE_AUTH_SALT. If any of those is missing from wp-config.php, or still says "put your unique phrase here", WordPress stores it in the database, and a database backup alone is then enough to decrypt your secrets. The settings screen warns you when this is the case.
To fix it, add a dedicated key of at least 32 random bytes to wp-config.php. Generate one with php -r 'echo base64_encode( random_bytes( 32 ) ), PHP_EOL;' (or wp eval 'echo base64_encode( random_bytes( 32 ) );') and add:
define( 'CODO_MAILER_ENCRYPTION_KEY', 'paste-the-value-here' );
Use a random value, not a memorable passphrase: the key is hashed without key stretching, so a short phrase is a weak key. Keys shorter than 32 characters are warned about.
Setting or changing the key makes existing saved secrets unreadable. To rotate it: set the new key, then re-enter each API key and password on the settings screen (secrets defined as constants in wp-config.php are unaffected). Keep the key out of version control and out of database backups, which is the point of keeping it in wp-config.php.
Yes, with the codo_mailer_capability filter, for example add_filter( 'codo_mailer_capability', fn() => 'edit_pages' );. The default is manage_options, or manage_network_options on multisite. Only give it to people you would trust with every account on the site. Anyone who can manage Codo Mailer can change the connection, so they can route all of the site's email, including password resets, through a server they control.
Even with the capability lowered, two things stay with administrators: reading message bodies in the email log, and turning Redact secrets off. Bodies can contain working password-reset links, and redaction is what keeps them out of the log. Other users see the log's recipients, subjects and errors, and can still resend emails.
email.<region>.api.aws), so sending works on hosts with IPv6-only outbound connections. Before, the IPv4-only email.<region>.amazonaws.com endpoint made these sends fail after a 10 second timeout.CODO_MAILER_PRIMARY_SESSION_TOKEN, or leave the access key ID blank to use the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN environment variables.codo_mailer_message filter to change an email before it is sent, for every provider.phpmailer_init does not run for Postmark, Brevo and SendGrid, and warn when a plugin on the site relies on it. The FAQ also explains that log retention depends on WP-Cron.codo_mailer_capability filter, only administrators can read logged message bodies or turn redaction off.codo_mailer_smtp_allow_plaintext_auth filter.codo_mailer_attachment_size_limit filter.