innocode-digital / wp-mail-helpers
覆盖邮件发件人头部,增加邮件功能检查。
1.2.1
2020-04-27 16:56 UTC
Requires
- php: >=7.0
- composer/installers: ~1.0
README
描述
覆盖邮件发件人头部,增加邮件功能检查。
安装
-
首选方法是使用 Composer
composer require innocode-digital/wp-mail-helpers
默认情况下,它将被安装为 必须使用插件。但您可以通过
composer.json
中的extra.installer-paths
来控制。 -
另一种方法是克隆此仓库到
wp-content/mu-plugins/
或wp-content/plugins/
cd wp-content/plugins/ git clone git@github.com:innocode-digital/wp-mail-helpers.git cd wp-mail-helpers/ composer install
如果插件作为常规插件安装,则从插件页面或 WP-CLI 中激活 Mail Helpers:wp plugin activate wp-mail-helpers
。
使用方法
常量
如果需要在所有电子邮件中覆盖 From 邮件头部,则应添加以下常量(通常添加到 wp-config.php
)
define( 'MAIL_FROM_ADDRESS', '' );
define( 'MAIL_FROM_NAME', '' );
注意
不需要同时设置两个常量,在大多数情况下,您只需要设置 MAIL_FROM_ADDRESS
。
插件设置了具有相当大优先级 9999
的钩子,但其他插件和主题可以设置更大的值,在这种情况下,您应根据需要更改优先级,例如。
if ( function_exists( 'innocode_mail_helpers' ) ) {
remove_filter( 'wp_mail_from', [ innocode_mail_helpers(), 'mail_from' ], 9999 );
add_filter( 'wp_mail_from', [ innocode_mail_helpers(), 'mail_from' ], 10001 );
}
设置
您可以在 WordPress 管理面板中设置 From 邮件头部:在 设置 > 邮件。应像 WordPress 验证 管理电子邮件地址 一样验证 发件人电子邮件。这些设置的优先级高于常量。
工具
插件添加了一个用于测试邮件功能的工具。您可以从 WordPress 管理面板的 工具 > 邮件 页面发送测试电子邮件。