• Resolved BookClubReader

    (@bookclubreader)


    The From field in the Mail section is not being passed into the email’s header. Each time I test it, the name of the website is returned as the sender. I have the following shortcode in the From field:

    [text-firstname] [text-lastname] <[text-email]>

    These shortcodes are also found in the email’s body, so I know they are being passed correctly in some places.

    Any suggestions?

    https://wordpress.org/plugins/contact-form-7/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter BookClubReader

    (@bookclubreader)

    Update: I am using Contact Form 7 in a multisite setup.

    I found a thread that helps move me in the right direction, but I’m still a bit lost. Any help would be greatly appreciated.

    Please include a link to your Contact Form 7 form plus all your input in the Form and Mail sections of the CF7 interface. If others here are able to understand your actual problem, they may be able and willing to offer a possible solution.

    Thread Starter BookClubReader

    (@bookclubreader)

    The site’s contact form uses a different shortcode than that above, but it’s the simplest form on the site. I’ll paste it below. In testing, the subsite contact forms worked fine. Only the messages sent from the main site of the network do not use the sender’s name. I had tested a different theme (2014). In the example below, the sender’s name uses the shortcode: [your-name]

    Form

    <table width="450px">
    <tr>
    <td width="40%">
    <p>Your Name *<br />
    Your Email *<br />
    Subject</p>
    </td>
    <td width="60%">
    <p><strong>[text* your-name]</strong>
        [email* your-email]
        [text your-subject] </p>
    </td>
    </tr>
    </table>
    <p>Your Message<br />
        [textarea your-message 60x] </p>
    
    <p>[submit "Send"]</p>

    ———————————-

    Mail Section
    From: [your-name] <[your-email]> <—
    Subject: [your-subject]

    Message Body

    From: [your-name] <[your-email]>
    Subject: [your-subject]
    
    Message Body:
    [your-message]

    ———————————-

    I’ve tried a variety of filters in the functions.php file. Since I’m not a programmer, any input on how to alter these to get something to work would be greatly appreciated.

    add_filter('wp_mail_from_name', 'site_mail_from_name');
    
    function site_mail_from_name ($mail_from_name) {
      $site_mail_from_name = get_option('site_mail_from_name');
      if( $mail_from_name != "Novel Blogs" || empty($site_mail_from_name) ) {
        return $mail_from_name;
      }
      else {
        return $site_mail_from_name;
      }}
    add_filter('wp_mail_from', 'doEmailFilter');
    add_filter('wp_mail_from_name', 'doEmailNameFilter');
    
    function doEmailFilter($email_address){
        if($email_address === "wordpress@mysite.hk")
            return 'contact@mysite.hk';
        else
            return $email_address;
    }
    function doEmailNameFilter($email_from){
        if($email_from === "WordPress")
            return 'MySite.com';
        else
            return $email_from;
    }

    Is there a way to add code that says, anytime an email is sent from CF7, it will use a filter for the from name?

    I could be wrong but I really don’t think your problem needs to be addressed by adding filters to functions.php – particularly if you are not a programmer.

    It looks ​​like a email sending issue to me due to your using the default [your-name] <[your-email]> as your From: email address.

    See Contact Form 7 Email Issues. There is a link at the bottom of the page to a comprehensive and detailed article which covers your issue.

    Thread Starter BookClubReader

    (@bookclubreader)

    Thanks for your input. However, the problem was BuddyPress. I found the answer here – Contact Form 7 – From Name Incorrect.

    Here’s what solved it for me:

    remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
    remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');

    I added this to my function file. If you have Genesis Extender, it’s easy to do.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Mail Section – From: Field Not Passed into Email’ is closed to new replies.