Personal tools
You are here: Home Products PloneFormGen Documentation Tutorials Creating a registration form Tricks for the email

Tricks for the email

A method to let the user choose if they want a copy of the form mailed to them as well as the recipient (you) of the default mailer.

The goal of the tutorial is to show how several of the 'How To' resources can be integrated together to create a customizable form connected to a MySQL database which will mail user input to the form owner and to others as defined in the setup.
Page 3 of 3.

Mailer Details

We want to add a second mailer to our folder that will send the form to the user. In order to do this we need to call on two separate tutorials:

 

First, we're going to add a selection field which will be populated dynamically with the user's email address. The catch is that we can only use selection fields for the Mailer, and the selection fields require at least two arguments. So, we'll title the selection field Receive Confirmation? and give it an id of email_conf.

 

 

In the 'overrides' panel under the Options Vocabulary add the following:

python: ((request.form['reg_email'],'Yes'),('junk@yourserver','No'))

This will create a field that asks the user if they want an email sent to them, if selected yes, can pass their email to our new mailer... which we're going to add now:

First, add a new Mailer in the form. Then, adapt the form for our purposes: directly from Steve's How-to:

Configuring the mailer

Now, edit the mail adapter for your form. (Navigate to the form folder, click on contents, find your mail adapter and follow the link; select the edit tab.)

Choose the [addressing] sub-form and find the Extract Recipient From field. You should see a None

choice and a list of all of the selection fields in your form. Select the field you just created and save your changes.

 

That's the basic gist... you should now have a form which updates a MySQL database with data entered on a form, and mails the entered data to both the form owner (you) and the user.