Page History: PHP-mailer Form Strategies
Compare Page Revisions
Compare revision
to revision
List of revisions
Page Revision: 2011/04/15 17:14
You can plan a strategy for an individual form.
Assumptions (for this document):
- install your phpmailer-fe.php and class.phpmailer.php in the
/_lib
directory. - install your form.html form in the root (/) directory.
note: the action of the form would be: action="proc/phpmailer-fe.php"
- Windows users should make the necessary changes to the directory names likely
substituting /_lib
with /cgi-bin
- note: if you are using any of the extended features of phpmailer-fe.php
please use a hidden field to include the name of the form.
Example:
- referer is required
You could then have
/_lib/default.config.php
- see the attached /sample_form/default.config.php
- this is was is called an External Configuration file. In this file, all of the form
fields, all of the PHPMailer-FE settings and variables can be over-ridden - and
is loaded by default (if it exists) and applies to ALL forms processed by PHPMailer-FE.
/_lib/form.config.php
- see the attached /sample_form/form.config.php
- this is was is called an External Configuration file. In this file, all of the form
fields, all of the PHPMailer-FE settings and variables can be over-ridden - and
totally unique only to this form
/_lib/form.tpl
- see the attached
/sample_form/form.tpl
- this is an E-mail template file that will be sent to the site administrator
($recipient)
It can be totally customized and include any of the form fields as a tokenized scalar
example: if a form field name is name="frmFirstname"
, you would call it from the
form.tpl
template as {frmFirstname
} - on execution, the form value will be substituted
customizing the form as you wish. You can use all the form field values, or only the
ones you want to email to the $recipient
.
Please note: there are two variables that are built into phpmailer-fe.php
that
you can access in your form template:
{IP} will substitute for the submitter's IP address
{HOST} will substitute for the submitter's Remote Host address (derived by PHP
from the IP address).
/_lib/replyemailfailed.html
- see the attached /_lib/replyemailfailed.html
- same description as the form.tpl
, except it is an email to indicate the failure of
the form submission. It will be sent to the field containing the name="email"
from
the form.html
form. You can also use tokenzied scalars.
/_lib/replyemailsuccess.html
- see the attached /_lib/replyemailsuccess.html
- same description as the form.tpl
, except it is an email to indicate the success of
the form submission. It will be sent to the field containing the name="email"
from
the form.html form. You can also use tokenzied scalars.
/formthankyou.html
- no example given, you can create in html, php or any other method to suit your needs.
/formfail.html
- no example given, you can create in html, php or any other method to suit your needs.
RECIPIENTS STRATEGY:
Using PHPMailer-FE is a fairly simple process. Essentially all you need to do is to drop
"phpmailer-fe.php" in a directory and use it as the action of your form.
If you do this, you will need to specify all the main attributes directly in your form,
especially who will be receiving the form data submitted by users.
You would do that by putting in a field something like this:
<input type="hidden" name="recipients" value="yourname@yourdomain.com">
The problem with this technique is that it leaves your email address exposed and will
likely be abused by email harvesters and automated form submission tools.
We recommend that you put the recipient email address in the script, as detailed in the
installation.txt
file.
USING FIXED EMAIL ADDRESS AND NAME FOR "FROM" FIELD:
If you have many forms you are processing on your site, you may also wish to consider one
aspect of using PHPMailer-FE. If you have created the form with a field called "email", the
form will be sent to the recipient using that email address. That is a good strategy if the
recipient plans on replying - the convenience is clear. However, if you have a lot of forms
and a lot of submissions, you may want to use filters to sort the submissions and file them
automatically.
There is an option in PHPMailer-FE:
$fixedFromEmail = ''; //'webmaster@thisdomain.com';
$fixedFromName = ''; //'Webmaster'
These are disabled by default (meaning the form will come from the email address submitting
the form (or
webmaster@yourdomain.com
if the field "email" is not found). If you want to have
a consistent strategy, you can fill in these fields.
REFERER ISSUE:
There is an option to restrict your installation of PHPMailer-FE to the domains you list in
this field. You do need to keep in mind a few points: