1

I have a question about changing the default sender From name/email on default wp_mail notifications (e.g., Lost Password response), but WITHOUT it messing up notifications being passed on by Gravity Forms.

I've found a few threads on changing the default From name/email, and this is what I ended up using. It did work properly to change the default sender from 'Wordpress' & 'wordpress@mydomain.com'.

// Change default WP email sender
add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');

function new_mail_from($old) {
return 'site-admin@mydomain.com';
}
function new_mail_from_name($old) {
return 'Site Admin';
}

But it ended up also changing all form submissions being passed on from Gravity Forms, as that just uses wp_mail to process the completed form submissions. The Gravity Forms submissions SHOULD retain the From name/email entered by the user when completing the form. This info is stored in the header and passed on to wp_mail for sending.

  • Is there a way to modify the function so it ONLY affects any mail being sent by the default address (Wordpress & wordpress@mydomain.com)? Maybe some sort of search/replace?

I'm also open to using SMTP sending if this could help and be more secure/robust. Unfortunately, I'm just not fluent in PHP to be able to write the function myself.

1

I think I found the answer on another forum discussing using Contact Form7, with the same issue I was having.

This is what I got from that thread and tried. It does appear to work and does appear to be only targeting email from the default 'Wordpress' sender name/email.

// Change default WP email sender
add_filter('wp_mail_from', 'doEmailFilter');
add_filter('wp_mail_from_name', 'doEmailNameFilter');

function doEmailFilter($email_address){
if($email_address === "wordpress@mydomain.com")
    return 'site-admin@mydomain.com';
else
    return $email_address;
}
function doEmailNameFilter($email_from){
if($email_from === "WordPress")
    return 'Site Admin';
else
    return $email_from;
}

Let me know if there is a better way to do this. Sorry if obvious...

0

I had a related issue and coded a plugin a few weeks ago. WP-HTML Mail doesn't support gravity forms now, but if you decide to change you form to Ninja Forms, the plugin is perfect for you. I added detectors for plugins to find out which plugin just sent the mail. Changing formatting and sender can be turned on/off for detected plugins.

0

I have an SMTP plugin that will set the default Sender Address and Sender Name, but still allow plugins (like Gravity Forms) to override these values.

https://wordpress.org/plugins/postman-smtp/

Having said that, depending on who your email accounts belong to, changing the Sender Email address to a different value than what you authenticate with may help mark your Email as Spam. Namely Gmail, Hotmail and Yahoo Mail.

  • Hey jason will this work for different mail domains say for example I am having gmail,Yahoo and some other mail domains say beyondigital.com,rizecorp.net can I use to send for all this emails and I want to include with GRAVITY FORMS plugins please help. – dh47 Jul 31 '15 at 6:33
  • No. One domain per site. – Jason Hendriks Aug 26 '15 at 21:01

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.