Formmail.php is a free script which delivers a user’s details from a form on your site’s contact page to your email inbox. It can do file uploads, it is spam savvy, it does captcha text.. phew, it threatens to fold your washing!
The file itself is more heavily documented than any other script I’ve seen: comments just about outweigh the code, which ironically makes it tedious to configure manually. Thankfully, Tectite offers a Configuration Wizard, which offers a free trial, or 7 day access for a measly US$4.95. I highly recommend that you use it.
If, however, you find yourself configuring it repeatedly, I’d suggest making your own configuration file. The purpose of this is to gather the 15 odd lines you actually need to edit on one page. Why is this so useful? Because the whole script weighs in at over 10,200 lines of code! That’s a lot of scanning through code.
Configuring formmail.php
First, enter your $TARGET_EMAIL, and define DEF_ALERT around line 230 in the script. This is well documented.
The essential step is to trigger formmail’s test function, which will email you the paths that it detects on your server. Do this by visiting the script directly in your browser:
name-of-your-formmail.php?testalert=1
then check your email. This will provide you with the correct path to use when configuring further options. I found recently, on a particularly convoluted server, that I needed the value PATH_TRANSLATED. Strip the trailing slash, and the script name off the end, so that you’re left with the a string ending in the directory containing the script:
Enter the following line into formmail.php before the comments begin (line 3)
include('config.php');
Now create a new file in the same directory as formmail.php, and name it, surprise.. config.php.
Browse through the script (the configuration is roughly between lines 230 and 520) and identify the variables that you want to set, and with each of them:
I think you’d be crazy negligent not to use the formmail.ini option, which protects your email address being harvested by separating it from the html form itself
I recommend having ALERT_ON_USER_ERROR set to true for the first week of operation, then set it to false when you tire of receiving a stream of mail notifying that someone has forgotten to enter a required field.
Caveats
This, of course, will need to be repeated if you upgrade. In the meantime, it could save you quite a bit of frustration if you’re running backwards and forwards between your configuration, your form, and your inbox. Tectite provides a really handy Upgrade Wizard, if you plan to follow the beaten path.
In Conclusion
I can’t help but think the formmail has been created obscure to scare people into using, and ultimately subscribing to the Configuration Wizard, but I don’t begrudge its author Russell Robinson this. Ten thousand lines of code don’t come from nowhere!
Formmail is a great product, and comes at the ultimate price, and it’s saved me a number of times.
Configure formmail.php more easily
Formmail.php is a free script which delivers a user’s details from a form on your site’s contact page to your email inbox. It can do file uploads, it is spam savvy, it does captcha text.. phew, it threatens to fold your washing!
The file itself is more heavily documented than any other script I’ve seen: comments just about outweigh the code, which ironically makes it tedious to configure manually. Thankfully, Tectite offers a Configuration Wizard, which offers a free trial, or 7 day access for a measly US$4.95. I highly recommend that you use it.
If, however, you find yourself configuring it repeatedly, I’d suggest making your own configuration file. The purpose of this is to gather the 15 odd lines you actually need to edit on one page. Why is this so useful? Because the whole script weighs in at over 10,200 lines of code! That’s a lot of scanning through code.
Configuring formmail.php
First, enter your $TARGET_EMAIL, and define DEF_ALERT around line 230 in the script. This is well documented.
The essential step is to trigger formmail’s test function, which will email you the paths that it detects on your server. Do this by visiting the script directly in your browser:
then check your email. This will provide you with the correct path to use when configuring further options. I found recently, on a particularly convoluted server, that I needed the value PATH_TRANSLATED. Strip the trailing slash, and the script name off the end, so that you’re left with the a string ending in the directory containing the script:
PATH_TRANSLATED: /home/www/01/mydomain.com.au/www/formmail/formmail.phpHijacking the Configuration
Enter the following line into formmail.php before the comments begin (line 3)
include('config.php');Now create a new file in the same directory as formmail.php, and name it, surprise.. config.php.
Browse through the script (the configuration is roughly between lines 230 and 520) and identify the variables that you want to set, and with each of them:
My config file looks like so:
<?php $TARGET_EMAIL = array(EMAIL_NAME."@mydomain.com$"); define("DEF_ALERT","tim@mydomain.com"); $LOGDIR = "/home/www/formmail/log"; $CSVDIR = "/home/www/formmail/csv"; $TEMPLATEDIR = "/home/www/formmail/templates"; $FORM_INI_FILE = "/home/www/formmail/formmail.ini"; define("FILEUPLOADS",true); $FILE_REPOSITORY = "/home/www/uploads"; define("CHECK_FOR_NEW_VERSION",true); define("CHECK_DAYS",30); $SCRATCH_PAD = "/home/www/formmail/scratchpad"; define("ALERT_ON_USER_ERROR",true); ?>A few thoughts before signing off:
Caveats
This, of course, will need to be repeated if you upgrade. In the meantime, it could save you quite a bit of frustration if you’re running backwards and forwards between your configuration, your form, and your inbox. Tectite provides a really handy Upgrade Wizard, if you plan to follow the beaten path.
In Conclusion
I can’t help but think the formmail has been created obscure to scare people into using, and ultimately subscribing to the Configuration Wizard, but I don’t begrudge its author Russell Robinson this. Ten thousand lines of code don’t come from nowhere!
Formmail is a great product, and comes at the ultimate price, and it’s saved me a number of times.
Formmail.php is available as a free download from Tectite.com, and they offer a Configuration Wizard.
Note: Of course, you’ll need to have PHP installed and running on your host (it’s free, and almost universal in budget setups).