Here is how you set up a form submission to automatically send a custom email back to the person who filled out the form. I am using this feature for a client who wants to distribute a PDF automatically to the user but wants to know who is downloading it. As opposed to just posting a link to download the PDF on their site I have created a form that the user must first fill out to get the PDF. Here is what you need to do to set something like this up for yourself:
1. Create a simple form in Facile Forms. It can ask for anything, but it needs to have a field for the user to input their email (or else the auto respond email will have no where to go!)
2. Once your form is complete, click on the “Manage Forms” button on the upper right hand of your screen. This will bring up a list of all your forms created within Facile Forms.
3. Click on the name of your form. (important: not the title, but the name)
4. Click on the tab “Submit Pieces”
5. Select the “Custom” radio button under the “Begin Submit” section and paste the following code into the box that appears:
// load the standard FacileForms library
$this->execPieceByName(‘ff_InitLib’);
//Sends confirmation e-mail to the visitor
$from = ff_getSubmit(‘cf_name’);
$this->sendMail(
$mosConfig_mailfrom, // email from name: as in config.php
$mosConfig_fromname, // email from addres: as in config.php
ff_getSubmit(‘cf_email’), // email address as filled in by visitor
‘Put Subject of Email Here’,
‘Dear ‘.$from.’,’.nl().nl(). ‘This is where you put your custom message’.nl().nl().
‘This is the last line of your custom message.’
);
6. Click Save & Test your form!
A few notes:
- The code for the script is really finicky. If you put one wrong period or space in there and it will throw a [Parse error: Syntax error, Unexpected T_String...] so be careful. I found it best to copy and paste the code into a text edit document and make my changes there, then copy and paste into the site when you are ready. This will help you keep track of what you have done & when in doubt return to my code provided if you mess up.
- The string [.nl().] found throughout the code are what create new lines. Put more of them together to create more space, use just one if you want a single line break.
- Be sure that the last line of your message ends with a ‘ and the whole code block ends with a );
- The ['Dear '.$from.','.nl().nl().] code string is what addresses the email. If you did not ask for the users name, this feature will not work.
- The variables used throughout (ie: cf_name) are based on what FacileForms auto generates for the name and email field titles. If you have changed yours to something custom, then you’ll need to update this code accordingly.