PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Send e-mail to addresses collected on form

  1. mmtrav
    Member

    Hi guys,

    This is a sweet plugin -- I'm going to switching to the dev license soon with my next web job. For the moment, however, I've encountered a roadblock and need some help.

    I am trying to create a referral program by which users submit e-mail addresses of their friends to the form and then the system sends a message out to those e-mail addresses FROM the original form submitter. Is this possible to program using the notifications system of Gravity Forms?

    I have already tried using the submitted form fields in the BCC area of the User Notifications. But the BCC e-mail doesn't appear to be going out so I'm not sure if submitted fields are a valid entry on the notifications page.

    I used the tokens that the notifications page generates plus I set up custom admin labels already. What Is it possible and if so, what do I need to do to get it to work?

    Posted 14 years ago on Sunday April 11, 2010 | Permalink
  2. mmtrav
    Member

    After searching around the forums (this wasn't an easy topic to search for) I found this post:

    http://forum.gravityhelp.com/topic/in-replace_variables-what-is

    However, I am still not getting the forms to send the e-mail to the BCC addresses successfully.

    I used the following code, and added it to a file called theme-functions.php (I use a WooTheme and I think this is where custom functions are supposed to go).

    // Gravity Forms BCC field
    add_filter("gform_pre_submission_filter", "add_bcc");
    function add_bcc($form){
        //change 2 to your actual form id
        if($form["id"] != 3)
            return;
    
        //Change the following input ids to match your fields.
        $bcc  = $_POST["input_3_4"] . ","; //friend 1 email
        $bcc .= $_POST["input_3_5"] . ","; //friend 2 email
        $bcc .= $_POST["input_3_6"] . ","; //friend 3 email
        $bcc .= $_POST["input_3_7"] . ","; //friend 4 email
        $bcc .= $_POST["input_3_8"]; //friend 5 email
    
        $form["notification"]["bcc"] = $bcc;
        return $form;
    }

    I'm also not sure if I used the right input fields. Here's the link to my form. The notifications seem to be going out, but the BCC fields are not being added successfully as no e-mail is received by my test addresses.

    I'm a little confused by whether I should use the name= field or the id= field from the form, as they are different in my form (probably because I've applied some conditional logic).

    Does somebody mind checking this out for me and letting me know where I may have gone wrong?

    I will also need the e-mail to come from the sender of the form too. but let's tackle this one issue at a time, shall we?

    Posted 14 years ago on Monday April 12, 2010 | Permalink
  3. Your code snippet is almost right, but you need to use the name instead of id.
    Try the following:

    // Gravity Forms BCC field
    add_filter("gform_pre_submission_filter", "add_bcc");
    function add_bcc($form){
    
        if($form["id"] != 3)
            return $form;
    
        //Change the following input ids to match your fields.
        $bcc  = $_POST["input_4"] . ","; //friend 1 email
        $bcc .= $_POST["input_5"] . ","; //friend 2 email
        $bcc .= $_POST["input_6"] . ","; //friend 3 email
        $bcc .= $_POST["input_7"] . ","; //friend 4 email
        $bcc .= $_POST["input_8"]; //friend 5 email
    
        $form["notification"]["bcc"] = $bcc;
        return $form;
    }

    Also, make sure you have the "Notification to User" active for this form in the notification screen.

    Let me know if you have issue with this.

    Posted 14 years ago on Monday April 12, 2010 | Permalink
  4. mmtrav
    Member

    Hi Alex,

    Thanks for getting back to me.

    Unfortunately that code snippet doesn't work for me. Two issues:

    1) At first I thought that users must give at least two e-mail addresses. But it appears that unless all five e-mail addresses are entered then the $bcc doesn't get added successfully. I'm not much for reading PHP but my guess is the extra commas might be causing the issue if only two e-mail addresses are submitted?

    2) The second issue is that when I put in all five e-mail addresses, the administration notification is sent via BCC, NOT the user notification.

    3) Finally, because of a lack of control over who is sending the e-mail addresses and to whom, the e-mail that does go out gets caught up in G-mail's spam filters as junk mail.

    Not a very ideal solution I'm afraid. Unless we can get around some of these issues I might have to create a different pathway by which this referral program works.

    Posted 14 years ago on Tuesday April 13, 2010 | Permalink
  5. You are right. My code snippet did not take into account emails being blank. I can fix that. It is also getting sent as the Admin notification and not the user notification. I can fix that too. We have pretty much total control over who the email goes to and who it came from. We also don't have to use the BCC to send the email out, we can use the TO field. Who do you want the email to be sent from?

    Posted 14 years ago on Tuesday April 13, 2010 | Permalink
  6. mmtrav
    Member

    Serious? you're willing to code that for me? Wow. I'm impressed. I guess this is why we call it a "premium plugins!"

    Okay, here's what would work for me:

    1) The Admin e-mail to go out to the admin as intended. I think it's better that notifications don't get their wires crossed..

    2) The user notification e-mail to should go to the user (the person who submits the referral) and their referred e-mail addresses, in the CC or TO field, as I'd like the e-mail to appear to be coming from a friend to other friends in a public way (no need to BCC them all). The source of the e-mail can still remain as the administrator.

    3) The form will allow up to five e-mail addresses to be submitted but requires only two e-mail addresses to be filled out and can handle anywhere between two e-mail addresses (and three blank entries) and five full e-mail addresses.

    4) Finally, I'm creating an option by which the user notification just goes to the user for them to forward the e-mail manually, in case they would prefer to do it themselves. So the form might not get any e-mail addresses at all. (See sample form that I'm still working on here).

    Posted 14 years ago on Tuesday April 13, 2010 | Permalink
  7. We are glad to help out when we can.
    I got myself in trouble on this one, though. Apparently the user notification does not give me all the flexibility that the admin notification does. It does not support custom CC or TO values, so our only option is to use the BCC field. What you can do is build the subject of the email to indicate that the message came from their friend. (i.e. Message sent from your friend John Doe). If this is acceptable, use the following:

    // Gravity Forms BCC field
    add_filter("gform_pre_submission_filter", "send_to_friends");
    function send_to_friends($form){
    
        if($form["id"] != 3)
            return $form;
    
        //Change the following input ids to match your fields.
        $bcc  = $_POST["input_4"] . ","; //friend 1 email
        $bcc .= $_POST["input_5"] . ","; //friend 2 email
    
        if(!empty($_POST["input_6"]))
            $bcc .= $_POST["input_6"] . ","; //friend 3 email
    
        if(!empty($_POST["input_7"]))
            $bcc .= $_POST["input_7"] . ","; //friend 4 email
    
        if(!empty($_POST["input_8"]))
            $bcc .= $_POST["input_8"] . ","; //friend 5 email
    
        $form["autoResponder"]["bcc"] = substr($bcc, 0, strlen($bcc)-1);
        return $form;
    }

    Note: It does require the first two emails to be filled out, so you will want to make them required in your form.

    Posted 14 years ago on Tuesday April 13, 2010 | Permalink
  8. mmtrav
    Member

    Hi Alex,

    Your code worked but my outgoing e-mails still didn't. After another search on the forum, I found the problem mainly to be related to spam issues. I followed instructions to reconfigure wordpress using SMTP and that should hopefully resolve most of the issues.

    I would suggest that next time you encounter this problem, please mention to the inquirer that they will need to reconfigure their mail send outs to circumvent this problem. Otherwise the referral program falls on its face because the e-mails don't go out!!

    In fact, Gravity Forms should tell users in its documentation that PHP mailing can be an issue.. setting up this referral program has been a real struggle.

    Thanks for helping me out with everything else!

    Posted 14 years ago on Sunday April 18, 2010 | Permalink
  9. I'm trying to setup a simple "Invite Friends" form.
    This would utilize the notification to user field.

    The desired function is to send email from friend 1 to friend 2.
    The current notification to user setup does not allow the "from email" to access a form input - i.e. {Your Email:3} How would I filter the "from email" to dynamically input the user email for this form?

    Thanks ;-)

    Posted 14 years ago on Tuesday April 20, 2010 | Permalink
  10. Hello,
    that's about what I seek. I would like the notification e-mail to the user send the page belongs.
    For explanation:
    Each user (Business) has a page with a contactform (or a link to it). If a visitor wants to contact the company they click on contact and is headed to the form. On the form is the e-mail address of the company had passed from that of the visitors.
    By submitting this form, the company gets the e-mail with the entire contents of the fields.
    Is this possible?
    Is it possible to e-mail address to take over from a Custom Field of the page?
    Or I can read the e-mail address from the profile page of the owner and pass on?

    Thanks for Help

    Posted 12 years ago on Friday March 16, 2012 | Permalink