Deactivate the mail plugin and add this snippet into your (child)theme functions.php file and give a try:
add_filter('wp_mail_from','custom_email_from');
function custom_email_from( $mail ) {
$mail = 'noreply@example.com'; // Replace the email address here //
return $mail;
}
I commented on this behavior in this ticket comment:
https://buddypress.trac.wordpress.org/ticket/7051#comment:3
BuddyPress sets the Reply-To
email header to the admin email’s address by default.
To override this, you have to use the 'bp_email_set_reply_to'
filter since 'wp_mail_from'
only handles the From
email address header and not Reply-To
header.
The following would work:
add_filter( 'bp_email_set_reply_to', function( $retval ) {
return new BP_Email_Recipient( 'noreply@example.com' );
} );
Thanks for your replies 🙂
@danbp your solution only changed From
email address. But i want to change Reply-to
email address to noreply@example.com
@r-a-y I placed your code in functions.php but when i tried to register, i am getting this error.
Fatal error: Call to a member function get_address() on string in /public_html/wp-content/plugins/buddypress/bp-core/classes/class-bp-phpmailer.php on line 94
It only appears when i use this code, or else it works fine. That’s weird :/
P.S I added it to class-bp-email.php
, it gives the same error! Recheck to code again, maybe you missed something or their is an error in the code 😀 @r-a-y or maybe i am adding the code in the wrong file, if yes then guide me where to add it 🙂
Try the updated code snippet in my previous post.
It WORKED! Thanks a lot @r-a-y. I really appreciate your help. 🙂
Cheers 😉
Hi everyone!
I couldn’t make it work, it is always sending with the admin email. Can anyone help me with this issue?
Here is the codes i tried:
add_filter( 'bp_email_set_from', function( $retval ) {
$user = wp_get_current_user();
return new BP_Email_Recipient( $user->data->user_email );
}, 99, 1 );
add_filter( 'bp_email_set_reply_to', function( $retval ) {
$user = wp_get_current_user();
return new BP_Email_Recipient( $user->data->user_email );
}, 99, 1 );
add_action( 'bp_email', function( $email_type, $email_obj ) {
$user = wp_get_current_user();
$email_obj->set_from( $user->data->user_email , "Custom Website Name" );
}, 99, 2 );
Hi,
Use this one to change from email.
add_filter('wp_mail_from','custom_email_from');
function custom_email_from( $mail ) {
$mail = 'noreply@example.com'; // Replace the email address here //
return $mail;
}
Thanks
Hi @prashantvatsh and everyone,
The problem was that i am using Easy WP SMTP and it overwrites the reply to header.
Sorry to ask without knowing this, but i hope it helps others anyway.
Thanks for your help!