i tried nearly anything to change the From / Reply-to name for the wp_mail() function.
Here is my code:
$headers = "From: \"FROM NAME\" <[email protected]>\n";
$headers .= "Return-Path: <[email protected]>\n";
$headers .= "Reply-To: \"FROM NAME\" <[email protected]>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "X-Mailer: PHP" . phpversion() . "\n";
$headers .= "Content-Type: text/plain; charset=\"". get_bloginfo('charset') . "\"\n";
add_filter('wp_mail_from','yoursite_wp_mail_from');
function yoursite_wp_mail_from($content_type) {
return '[email protected]';
}
add_filter('wp_mail_from_name','yoursite_wp_mail_from_name');
function yoursite_wp_mail_from_name($name) {
return 'FROM NAME';
}
wp_mail("[email protected]", "Subject", "Content", $headers);
I also tried to move the filters to the functions.php. But it doesn't matter what I try it is always the same from address when I receive the email. It seems that a plugin overrides the filters & headers because it is not the standard [email protected] address but I've searched through all plugins with the plugin String Locator and I can't find it though.
Do you have any advice?
Thanks in advance!
add_filter('wp_mail_from','yoursite_wp_mail_from', 999);