应用标题的方式不正确。您设置了一个;“自”;在标头中以字符串形式显示地址,然后立即用数组覆盖该地址(因此“发件人”地址将丢失)。(您还设置了两次$发件人地址)
可以这样尝试:
function send_email(){
$to = $email;
$subject = "Lamza Activation";
$activationEmail = \'\';
$from = "testing <[email protected]>";
$headers[] = "From:" . $from . PHP_EOL;
$headers[] = \'Content-Type: text/html; charset=UTF-8\';
wp_mail($to, $subject, $activationEmail, $headers);
}
或者,您也可以使用
wp_mail
筛选以设置发件人地址和内容类型。
function send_email(){
$to = $email;
$subject = "Lamza Activation";
$activationEmail = \'\';
wp_mail($to, $subject, $activationEmail);
}
add_filter( \'wp_mail_from\', function( $from ) {
return "[email protected]";
});
add_filter( \'wp_mail_from_name\', function( $from_name ) {
return "testing";
});
add_filter( \'wp_mail_content_type\', function( $content_type {
return \'text/html\';
});
// This one you may not need as WP defaults to UTF-8...
add_filter( \'wp_mail_charset\', function( $charset ) {
return \'UTF-8\';
});