默认情况下,WordPress 通过 mail() 函数发送的邮件的发件人是:WordPress < wordpress@xxx.com >,这样一般是没办法让收件人直接回复的,而且很容易进入垃圾箱。

其实,我们可以通过 wp_mail_from 和 wp_mail_from_name 来修改 WordPress 发送邮件的默认邮箱和发件人。将下面的代码添加在主题的 functions.php 最后一个 ?> 的前面:
//change WordPress default mail_from information
function new_from_name($email){
$wp_from_name = get_option('blogname');
return $wp_from_name;
}
function new_from_email($email) {
$wp_from_email = get_option('admin_email');
return $wp_from_email;
}
add_filter('wp_mail_from_name', 'new_from_name');
add_filter('wp_mail_from', 'new_from_email'); |
//change WordPress default mail_from information
function new_from_name($email){
$wp_from_name = get_option('blogname');
return $wp_from_name;
}
function new_from_email($email) {
$wp_from_email = get_option('admin_email');
return $wp_from_email;
}
add_filter('wp_mail_from_name', 'new_from_name');
add_filter('wp_mail_from', 'new_from_email');
上面的代码会将 默认发件人 修改为 网站的名称 ,默认邮箱 为 管理员的邮箱
当然了,你也可以直接设定,比如我将 发件人设为 胡倡萌 ,邮箱 设为 admin@xxx.com ,直接修改下面两处:
$wp_from_email = 'admin@xxx.com'; |
$wp_from_email = 'admin@xxx.com';
好了,自己折腾吧!
来源:
https://www.wpdaxue.com/change-wordpress-mail-from-info.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_32487.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57