1

I want to set a custom from email address for emails that are sent via a plugin. I don't want to change default email address. The following code is not working:

add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');

function new_mail_from($old) {
 return 'your email address';
}
function new_mail_from_name($old) {
 return 'your name or your website';
}
  • This should work, except when the email you are trying to change are not sent using wp_mail(). – fuxia Jul 30 '19 at 9:39
  • yes I need that solution , the email which are not send using wp_mail() – Pranav Patel Jul 30 '19 at 9:44
  • 1
    Then you can't. Fix the code to use wp_mail() instead. – fuxia Jul 30 '19 at 13:52
0

Please use this below code for sending emails in wordpress, which will change the from name.

$recipient_email = "mymail@mail.com";
$subject ="Submission";
$message = "I have done a submission"; 
$headers = 'Content-type: text/html;charset=utf-8' . "\r\n"; 
$headers .= 'From: Mastic Technology Rebate <donotreply@plygem.com>' . "\r\n";
wp_mail($recipient_email, $subject, $message, $headers);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.