Support » Plugin: Contact Form 7 » The "From" Name gets overwritten by wp_mail function

  • Resolved amitramani


    The problem reported is that the emails generated by the forms have the “Site Title” in the email From header , instead of the actual one that it should get from whatever the user entered.

    I have looked into the classes.php code and tried to debug it. No luck. The email address is correct, just not the name. I have even tried adding the ‘wp_mail_from_name’ hook also, but to no avail.

    I have made sure the From field is set correctly within the WP Admin.

    At this point, I am running out of options. When I put debug statements in the core wordpress code (inside the wp_mail() function within wp_includes/pluggable.php), I notice that the “From” name gets reset to the “Site Title” after the following call:
    $phpmailer->FromName = apply_filters( ‘wp_mail_from_name’, $from_name );

    Any ideas or suggestions?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Takayuki Miyoshi


    Try deactivating all other plugins and switching to the default theme.

    Thread Starter amitramani


    Because the form is connected to products sold via JigoShop plugin, I had to leave the JigoShop plugin enabled.

    Out of curiosity, I grepped the JigoShop code for ‘wp_mail_from_name’….and there it was a call to add_filter(‘wp_mail_from_name’…..) without a corresponding call to remove_filter().

    Once I removed the call to add_filter() from the JigoShop code, the “From” field is populating correctly. The add_filter() call in JigoShop is redundant anyway, because every invocation of wp_mail() from JigoShop sets the “headers” field anyway.

    Thanks for your help. Contact Form 7 is a great plugin, good work.

    Phew…that was my first foray into WordPress code. Thank you for the guidance!

    If you identify a conflict with a particular plugin or theme, you could write to the plugin or theme developer and suggest they might have a possible conflict with CF7.

    CF7 is one of the most popular plugins in the WordPress Repository, so it makes sense for developers to deal with any potential conflicts.

    Also if a plugin or theme conflicts with CF7, it probably also conflicts with many other plugins. It’s generally a sign of a poorly coded theme or plugin and one that people should avoid using.

    Thread Starter amitramani


    Thanks for the suggestion. I will write to the developer of JigoShop (possibly post in that forum) about this conflict.

    Funny thing is that the code for <strong>add_filter('wp_mail_from', ...)</strong> is already commented, but the one for add_filter('wp_mail_from_name', ...) is not commented out.

    Maybe it got left behind as an artifact. Either way, I will communicate with JigoShop development team.

    Thread Starter amitramani


    I posted on the JigoShop forum a new thread elaborating the issue. No response yet.

    I am not sure how active that forum is.

    Any other ideas? I will try contacting the author directly via email as well.

    Thank you WP Newbie, you have gone above and beyond finding this solution.

    This now has been fixed, in accordance with the guidance given by the official JigoShop development team. WP Newbie was able to confirm with the JigoShop team that his proposal for the fix is acceptable. They have acknowledged the issue and are going to include this fix in the next official JigoShop release.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘The "From" Name gets overwritten by wp_mail function’ is closed to new replies.