Viewing 21 posts - 1 through 21 (of 21 total)
  • Author
    Posts
  • #1125607

    Hello. On my page I have added a “Contact Form” element. When a user submits the form, an email with the form data is delivered to the expected email account. In that email, the ‘From’ name and email address is set to an email address belonging to my company (e.g. (Email address hidden if logged out) ). How can I change the ‘From’ name and email address on this email?

    In the form element settings is a field, ‘Autoresponder from email address.’ I tried entering an email address there, saving it, and re-submitting my form. But when the email arrived, but nothing changed–the same ‘From’ name and email address were specified (i.e. (Email address hidden if logged out) ).

    Thanks.

    #1126509

    Hey FeedXL2019,
    Sorry for the late reply, please see this post for a list of functions to change the “from” address and autoresponder address, one of these should help, perhaps the first one.

    Best regards,
    Mike

    #1126601

    Hi Mike,

    Thanks for the reply. To be clear, my issue has nothing to do with the auto-responder–I have not yet enabled that. I would like to change the ‘from’ address and the ‘reply to’ address. So in the link you sent, it seems like the code in these sections would apply to me:

    > Or if you just want to change the “from” address:
    > If you need to add a “reply to” address so it won’t be marked as spam:

    Is that correct? If so, I added this code to my functions.php file:

    // change from address
    add_filter('avf_form_from', 'avf_form_from_mod', 10, 3);
    function avf_form_from_mod($from, $new_post, $form_params) {
        $from = " (Email address hidden if logged out) ";
        return $from;
    }
    
    // add reply-to in mail header
    add_filter( 'avf_form_from', 'enfold_customization_contact_form_etc', 10, 3 );
    function enfold_customization_contact_form_etc( $from, $p1, $p2 ) {
      global $enfold_custom_from_header;
      $enfold_custom_from_header = $from;
    }
    add_filter( 'avf_form_mail_header', 'enfold_customization_contact_form_etc2', 10, 3 );
    function enfold_customization_contact_form_etc2( $header, $p1, $p2 ) {
      global $enfold_custom_from_header;
      $header .= 'Reply-To: ' . $enfold_custom_from_header . '\r\n';
      return $header;
    }

    But when I tested my form, there was no change–the ‘from’ field was still populated by (Email address hidden if logged out) ‘ Thoughts?

    I checked the WordPress PHP error log, but nothing was written.

    Thanks.

    #1126644

    Hi,
    Thanks for the feedback, I have tested the default email header for Enfold v4.5.7 and confirm that the from address is correct.
    So I checked your site and see that you are using Enfold v4.0.7 which is very outdated.
    Please try updating your theme to correct this.

    Best regards,
    Mike

    #1126647

    Thanks for the reply. Here are my follow-ups.

    >> So I checked your site and see that you are using Enfold v4.0.7 which is very outdated

    Can I ask what site you checked? My production site is on https://feedxl.com/, but my dev site is on https://wordpress-dev.feedxl.com/. The theme on my production site is indeed out of date. The issue I am experiencing is part of a larger task to update the theme. I have already updated the theme on my dev site, to the latest version. And it is on that site that I am experiencing these email issues. In light of that, how can we troubleshoot the issue? If you would like admin access to my dev site, I am happy to create a user for you.

    Thanks.

    #1126671

    Hi,
    Thanks for the feedback, Try adding this code to the end of your functions.php file in Appearance > Editor:

    add_filter('avf_form_from', 'enfold_contact_form_change_from', 10, 3);
    function enfold_contact_form_change_from($from, $new_post, $form_params) {
            global $enfold_visitor_from;
            $enfold_visitor_from = $from;
            $from = "info@<domain>";
            return $from;
    }
    
    add_filter( 'avf_form_mail_header', 'enfold_contact_form_add_replyto', 10, 3 );
    function enfold_contact_form_add_replyto( $header, $p1, $p2 ) {
            global $enfold_visitor_from;
            $header .= 'Reply-To: ' . $enfold_visitor_from . "\r\n";
            return $header;
    }

    please be sure to change the email address in the code and test on a current version, I tested on v4.5.7 and it works correctly.

    Best regards,
    Mike

    #1126724

    Hi Mike,

    Actually I think I figured out the issue. The site has a pluing–WP Mail SMTP–which appears to be interfering with this. When I deactivated the plugin, my issues disappeared. So let me investigate that plugin. I think we can consider this resolved.

    #1126787

    Sorry Mike, I’m back, and not yet finished with this :-/ I deactivated the WP Mail SMTP plugin, and added your code. What now occurs is that the email is delivered, and it has the correct ‘From’ email address. But there is no name in the ‘From’ field–there is only an email address (screenshot). What I would like is for this field to display with a name and an email address, like this. How can I accomplish that? As a test, in your code, I replaced the email address with:

    FeedXL Support < (Email address hidden if logged out) >

    But when I did so, the email was never delivered.

    If I remove your code completely, then submit the form, the email is delivered. But the ‘From’ email field is populated with the email address of the sender (screenshot). That is of course not desirable.

    Thanks.

    #1127059

    Hi,
    I changed the function to include a name and email in the from line of the email header and it seems to be working on my localhost mail server, but for some reason, the last letter of the name, “support” in this case, is dropped, so add an extra letter like “supportt”

    add_filter('avf_form_from', 'enfold_contact_form_change_from', 10, 3);
    function enfold_contact_form_change_from($from, $new_post, $form_params) {
            global $enfold_visitor_from;
            $enfold_visitor_from = $from;
            $from = 'supportt'.'<'.  (Email address hidden if logged out) ' .'>'."\r\n";
            return  $from;
    }
    
    add_filter( 'avf_form_mail_header', 'enfold_contact_form_add_replyto', 10, 3 );
    function enfold_contact_form_add_replyto( $header, $p1, $p2 ) {
            global $enfold_visitor_from;
            $header .= 'Reply-To: ' . $enfold_visitor_from . "\r\n";
            return $header;
    }

    here’s a screenshot of the resulting header:
    2019-08-12-232217

    Best regards,
    Mike

    #1127098

    Hi Mike,

    OK that code worked as you described, thanks very much. But…my requirements actually suddenly changed slightly :-/ The ‘From’ field should not be populated with FeedXL Support < (Email address hidden if logged out) > as I previously mentioned. It should actually be populated with the name and email address of the person sending the inquiry. To be specific, the form in-question has a ‘Name’ field and an ‘E-mail’ field. Let’s say a person named John Smith, with an email address of (Email address hidden if logged out) , submits the form. When the form is submitted, I want the resulting email to have a ‘From’ field populated with: John Smith < (Email address hidden if logged out) > How would I modify the code you gave me to do so? It looks like I may need to use the $form_params variable? The $form_params array seems to contain the email address I need, but it does not contain the value of the ‘Name’ field in the form–that is something I need.

    Also, I amended your code with my own name/email address (as below). But the resulting email has a ‘From’ name that is truncated by one digit (screenshot). Thoughts on why that is occurring and how to resolve it?

    add_filter('avf_form_from', 'enfold_contact_form_change_from', 10, 3);
    function enfold_contact_form_change_from($from, $new_post, $form_params) {
            global $enfold_visitor_from;
            $enfold_visitor_from = $from;
            $from = 'FeedXL Support'.'<'. ' (Email address hidden if logged out) ' .'>'."\r\n";
            return  $from;
    }

    The reply-to field can remain as-is.

    Thanks.

    • This reply was modified 5 years, 2 months ago by FeedXL2019.
    #1127461

    Hi,
    Ok, so you would like to have the default “from” email header, which is the sender’s email address, but also include the name of the sender in the field, and you would also like to add the “reply-to” field in the header with the sender’s address?
    Unfortunately, I have not been able to do this and have asked the team to assist.

    But in my research, I found that some server spam filters require the “from” address to match the domain of the contact form and the “reply-to” address be used with the address of the person filling out the form.
    You may want the ask your webhost what, if any, requirements they have for email headers from your contact form.

    Best regards,
    Mike

    #1127475

    Hi Mike,

    >> so you would like to have the default “from” email header, which is the sender’s email address, but also include the name of the sender in the field, and you would also like to add the “reply-to” field in the header with the sender’s address?

    That is correct. I would like the ‘From’ field to be dynamically populated with the sender’s name and email address, and I would like the ‘reply-to’ field to be dynamically populated with the sender’s email address. I have been able to do the latter (with the code you gave me). And I can do 50% of the former–I can add the sender’s email address, but not name (see below).

    >> Unfortunately, I have not been able to do this and have asked the team to assist.

    OK please let me know what they say.

    >> But in my research, I found that some server spam filters require the “from” address to match the domain of the contact form and the “reply-to” address be used with the address of the person filling out the form.
    >> You may want the ask your webhost what, if any, requirements they have for email headers from your contact form.

    OK I will ask my web host (SiteGround) if they impose any requirements there. But I’m not sure that my web host would be affecting how we populate the ‘From’ field in this PHP code, especially in light of everything I’ve been able to do so far. To be clear, so far in our exercise I have been able to dynamically populate the ‘reply-to’ field with the sender’s email address (as desired). I have also been able dynamically populate the ‘From’ field with the sender’s email address (as desired). Lastly, I am able to insert any static name I want into the ‘From’ field–but this is not desired. I want to dynamically insert the sender’s name to the ‘From’ field. To me it seems like the issue is due to the fact that the $form_params array does not possess any of the form data that the sender submitted (i.e. ‘Name’ ‘E-mail’ or ‘Enquiry’). If I was able to access that data from this particular PHP function, it would resolve my issue.

    As a test, from my PHP function I printed the value of the $_POST super global variable, to see if it would contain the info I want. It kind of does. Here is what it prints (see below). The first three elements in the array are the form values submitted by the sender (e.g. Name, E-mail, and Enquiry). But as you can see, they are not exactly formatted as desired.

        [avia_1_1] => Carl%20Gross
        [avia_2_1] => cagross%40gmail.com
        [avia_3_1] => testmessage
        [avia_4_1] => 
        [avia_generated_form1] => 1

    Thoughts on that? I could use this as perhaps a last ditch workaround. But I’d really like to know what your devs have to officially say about this. What I’m trying to do is a relatively common feature of WordPress contact forms. For example, the popular plugin Contact Form 7 allows one to easily change the ‘From’ name to dynamically match the name of the sender (screenshot).

    Finally, it turns out that this issue is now a bit critical on my end, since a similar issue is now affecting our production site. If you’re able to fast track your research a little, I’d appreciate it :-)

    Thanks for your help so far.

    PS – What about my separate issue with the truncation in the ‘From’ field? As you can see from my code, I set my ‘From’ field to:

    $from = 'FeedXL Support'.'<'. ' (Email address hidden if logged out) ' .'>'."\r\n";

    But in the email, the ‘t’ in ‘FeedXL Support’ was missing. That continues to be the case. Any ideas why?

    Sorry, one more question. I have confirmed that the PHP code you gave me applies to the form on my Contact page. But I also have a similar form on two other pages. Does the PHP code apply to all three forms? If so, how would I customize the PHP code to apply to only the form on the Contact page? Can I use $form_params to somehow check which specific form is in-use?

    • This reply was modified 5 years, 2 months ago by FeedXL2019.
    #1127501

    Hi,
    Glad to hear you will ask your web host if this will cause any issues with your server spam filters, I just thought I should point this out when I came across it in my research. As for the truncation in the ‘From’ field, I don’t know why this is, but you will see above that I pointed this out when I posted the code above, so I look forward to seeing the solution also to see where my error was.
    It may take some time to hear back as we are all in different countries and different time zomes, Thank you for your patience.

    Best regards,
    Mike

    #1127674

    Hi Mike,

    Actually, I was able to resolve a lot of my issues (but not all). I was able to figure out how to dynamically populate the ‘From’ field with form data–that data is contained in the $new_form input parameter. So that resolves those issues. Also, that tells me how to target specific forms if need be, so that issue is resolved as well. But the truncation issue is still present.

    Also, I’m experiencing a new issue. If I specify the form to be delivered to (Email address hidden if logged out) , and a user submits the form, the email is delivered as expected. But when I change it to (Email address hidden if logged out) , the email is not delivered. Any ideas how to troubleshoot that?

    #1127840

    Hi,
    Please try using the plugin: WP Mail Logging to see if the email is being sent from your site. Then try removing your function and test again to see if the email is getting from your site to your mail server.

    Best regards,
    Mike

    #1127916

    Hi Mike,

    >> Please try using the plugin: WP Mail Logging to see if the email is being sent from your site.

    OK I installed the plugin, then submitted the contact form. An entry was added to that log, which indicates that the email is indeed sent–correct?

    >> Then try removing your function and test again to see if the email is getting from your site to your mail server.

    I removed all custom PHP code I’ve added during this exercise. When I do so, emails *are* delivered to the recipient email address, as expected.

    One thing we have overlooked during this exercise is that my live site is on feedxl.com. But I have been doing all testing on my dev site, which is on wordpress-dev.feedxl.com. So, as a test, I just tried setting the name/email address in the ‘From’ field to FeedXL Support < (Email address hidden if logged out) >, so it is from an email address on my domain. When I did so, and submitted the contact form, the email *was* delivered as expected. BUT, the ‘From’ field in the email was set not to FeedXL Support < (Email address hidden if logged out) > as expected. It was set to (Email address hidden if logged out) . Any ideas why that is occurring or how to fix it? I am essentially back to square one–the ‘From’ field is populated with (Email address hidden if logged out) , which was my original issue.

    To be clear, this is the PHP code currently added to my site:

    function enfold_contact_form_change_from($from, $new_post, $form_params) {
            global $enfold_visitor_from;
            $enfold_visitor_from = $from;
            $from = 'FeedXL Support' . '<'. ' (Email address hidden if logged out) ' .'>' . "\r\n";
    
            return  $from;
    }
    add_filter('avf_form_from', 'enfold_contact_form_change_from', 10, 3);
    
    function enfold_contact_form_add_replyto( $header, $p1, $p2 ) {
            global $enfold_visitor_from;
            $header .= 'Reply-To: ' . $enfold_visitor_from . "\r\n";
            return $header;
    }
    add_filter( 'avf_form_mail_header', 'enfold_contact_form_add_replyto', 10, 3 );
    • This reply was modified 5 years, 2 months ago by FeedXL2019.
    #1127980

    Hi Mike,

    I have an update. I resolved the issue of emails not being delivered. The issue is that I was specifying the same email address in both the ‘From’ and ‘To’ fields. Our email provider (G-Suite) does not allow this. So when I changed the email address in the ‘From’ field, the issue was resolved. I thought I had previously tested that, but I guess not. So let’s consider that resolved.

    I am however still experiencing the new issue I raised in my previous message. Namely, when the email is delivered to my destination email account, the ‘From’ field is populated with (Email address hidden if logged out) , even though I have specified otherwise in my custom PHP code. Any ideas how to troubleshoot that? Here is the code currently on my site (it is a little different from the code I specified in my previous message):

    function enfold_contact_form_change_from($from, $new_post, $form_params) {
            global $enfold_visitor_from;
            $enfold_visitor_from = $from;
            // $from = 'FeedXL Support'.'<'. ' (Email address hidden if logged out) ' .'>'."\r\n";
            $from = urldecode($new_post['1_1']) .'<'. urldecode($new_post['2_1']) .'>'."\r\n";
    
            return  $from;
    }
    add_filter('avf_form_from', 'enfold_contact_form_change_from', 10, 3);
    
    function enfold_contact_form_add_replyto( $header, $p1, $p2 ) {
            global $enfold_visitor_from;
            $header .= 'Reply-To: ' . $enfold_visitor_from . "\r\n";
            return $header;
    }
    add_filter( 'avf_form_mail_header', 'enfold_contact_form_add_replyto', 10, 3 );

    The issue is present even if I remove

    $from = urldecode($new_post['1_1']) .'<'. urldecode($new_post['2_1']) .'>'."\r\n";

    and replace it with

    $from = 'FeedXL Support'.'<'. ' (Email address hidden if logged out) ' .'>'."\r\n";

    Thanks.

    • This reply was modified 5 years, 2 months ago by FeedXL2019.
    #1128035

    Mike,

    I have two updates:

    1. Ignore the issue related to the ‘From’ field populated with (Email address hidden if logged out) . I figured out the cause of that (a plugin confict) and resolved it.

    2. I’m very sorry, but the mail delivery issue is unfortunately still present. To be specific, if I specify the form to be delivered to (Email address hidden if logged out) (or any other feedxl.com email address), then submit the form, the mail is sent, but not delivered. I say it is sent because the WP Mail Log plugin records these mails as being ‘sent.’ But they never arrive at the desired email account. But, if I instead specify the form to be delivered to a non-feedxl.com email address (e.g. (Email address hidden if logged out) ), then the mail is sent *and* delivered successfully. Thoughts on that?

    And I have more info on this mail delivery issue. If I remove all custom PHP code I’ve added as part of this exercise, and specify the form to be delivered to (Email address hidden if logged out) (or any other feedxl.com email address), then submit the form, the mail is sent, but not delivered. Any ideas why, or how to troubleshoot that?

    Thanks.

    PS: And I have yet another update. The mail delivery issue *seems* to have been resolved. The emails were being delivered to my spam folder. I should have checked that a long time ago :-/ But give me a couple more days to confirm that everything is working as expected, then I can hopefully close this ticket (although the truncation of the name in the ‘From’ field is still present).

    • This reply was modified 5 years, 2 months ago by FeedXL2019.
    #1128782

    Hi,

    Thank you for the update.

    Glad to know it’s fixed. We’ll keep the thread open.

    Best regards,
    Ismael

    #1130065

    OK everything is now working as expected. Thank you for the help. We can consider this resolved.

    #1130132

    Hi FeedXL2019,

    Glad you got it working for you! :)

    If you need further assistance please let us know in another thread.

    We are closing this thread.
    Best regards,
    Victoria

Viewing 21 posts - 1 through 21 (of 21 total)
  • You must be logged in to reply to this topic.