Templates | Large Forms | SPAM Protection | Database Integration | FormMemory | Miscellaneous

Posting Form Data to E-Mail
post2email.php Advanced Features

Comment: post2email.acgi, which runs natively on the classic MacOS, has reached end-of-life. It has been replaced with post2email.php, which runs natively on Unix systems, such as MacOSX and MacOSX Server. New features introduced with post2email.php are noted in green.

Related Links

Using Templates

If sortOrder is set to "_template", then the file specified at the path contained in the field "templatefile" will be used to format the email. Here is a skeletonized sample form:
<form name.... . . ....> <input type="hidden" name="sortOrder" value="_template"> <input type="hidden" name="templatefile" value="/Users/you/Sites/your_templatefile.txt"> . . . Last Name <input type="text" name="lastname" size="24" value=""><br> First Name <input type="text" name="firstname" size="18" value=""><br> . . . </form>
Sample template file...
Someone with the last name of $lastname and the first name of $firstname has completed and submitted a form.
Those familiar with PHP will be instantly comfortable with this format. For the rest, just put a dollar sign in front of the field name where you want the submitted value substituted for the placeholder.

Caveats - be careful not to name your fields with names which are leading substrings of others. For example, be careful using "fieldname1" and "fieldname11". Experimenting with this is left as an exercise for the user. Also, be certain the template file is readable by the www user (it probably will be, but knowing a little Unix is very handy).

Managing & Organizing Large Forms

metaSortOrder
if sortOrder is set to "_meta", then the fields listed in metaSortOrder are combined to produce the sort order. This is useful for occasions when there are numerous fields that need some organization/compartmentalization. This feature was not fully tested in the acgi version, but is robust in the php version. Skeletonized sample code follows:

<form name.... . . ....> <input type="hidden" name="sortOrder" value="_meta"> <input type="hidden" name="metaSortOrder" value="personal,business"> <input type="hidden" name="personal" value="firstname,lastname"> <input type="hidden" name="business" value="businessname,businessphone"> . . . Last Name <input type="text" name="lastname" size="24" value=""><br> First Name <input type="text" name="firstname" size="18" value=""><br> . . . </form>
except
if you define a hidden field named except, then all fields except the ones listed in the "except" field are returned, in the order they appear in the HTML. The format is the same as for a simple sortOrder field. It is the HTML designer's responsibility to exclude admin fields (if desired). This feature makes it easier to design forms with many fields. You may choose to set sortOrder to "_except", but this is optional. If a non-empty except field exists, it will override sortOrder (so be careful).

Tip: If you want all fields to be returned (including the normally excluded admin fields), put a non-existent field name in the except field.
Another Tip: If you leave out the sortOrder and except fields entirely, all non-admin fields are passed, in order, with a comment stating so. Any field name which begins with "helper_" is considered to be an admin field, which provides you with another method of controlling which fields get passed to the recipient. There are probably several permutations of this, so feel free to test them. The fail-safe defaults should cover you well.

Here is a sample field definition for excluding all the admin fields:
<input type="hidden" name="except"
value="recipient,responsePage,errorPage,fromUserFieldName,required,introLine,
echoBlanks,sortOrder,metaSortOrder,except,debug,suppressFieldnames,formName">
Top

Spam Protection Features

If you use the sample code provided on the main post2email page, your recipient email address is fully exposed to nasty robots which scour the Web for addresses to spam. Here is a simple way to declare the recipient in a spam-proof manner:
<input type="hidden" name="recipient" value="you(shift-2)yourcompany(dot)com">
The (shift-2) will be replaced with @ and the (dot) will be replaced with "." (a lone period). (period) will also be converted to ".". In the PHP version, (at) will be replaced with @.

For the second level of 'bot-spoofing, if the string "_p2em_" is included anywhere in the mangled email address, it will be removed. This is actually done before conversion of (shift-2), (dot), (at), and (period).

For the third level, you can define your own string swap as follows:
<input type="hidden" name="helper_spamblockfrom" value="_re_place_this_"> <input type="hidden" name="helper_spamblockto" value="com">
The string defined in helper_spamblockfrom will be replaced with the string in helper_spamblockto. Using all these techniques, the code looks like this:
<input type="hidden" name="recipient" value="you(shi_p2em_ft-2)your_re_pla_p2em_ce_this_pan_p2em_y(dot)_re_place_this_"> <input type="hidden" name="helper_spamblockfrom" value="_re_place_this_"> <input type="hidden" name="helper_spamblockto" value="com">
I very much doubt any robots will be able to deduce the actual email address with all these obfuscations! Of course, all these features are optional.
Top

Database Integration

If you wish, you may have the output sent to a MySQL database viewable (and editable) thru a Web Page interface (Safari from Apple strongly recommended - seriously, and not because I am a Mac nut.) The output can be configured to be either emailed, archived, or both, controllable thru custom form fields which will be made available to premium customers.
Top

FormMemory Compatibility

There is a potential incompatibility between LinkedResources' post2email and FormMemory tools. The problem is that a FormMemory archive can overwrite the post2email admin fields. The workaround is to change the names of the admin fields to helper_adminfieldname. For example, instead of using a recipient field, name it helper_recipient. If you define a field named helper_recipient with a non-blank value, then only fields which begin with "helper_" will be recognized as admin fields. Here then is the sample form, now both FormMemory savvy and spam proof:
<form name="sample" method="post" action="http://post2email.yourcompany.com/this_is_a_fake_URL.acgi/php"> <input type="hidden" name="helper_recipient" value="you(shi_p2em_ft-2)your_re_pla_p2em_ce_this_pan_p2em_y(dot)_re_place_this_"> <input type="hidden" name="helper_spamblockfrom" value="_re_place_this_"> <input type="hidden" name="helper_spamblockto" value="com"> <input type="hidden" name="helper_responsePage" value="http://www.yourcompany.com/thankyou.html"> <input type="hidden" name="helper_errorPage" value="http://www.yourcompany.com/formerror.html"> <input type="hidden" name="helper_fromUserFieldName" value="emailaddress"> <input type="hidden" name="helper_required" value="lastname,firstname"> <input type="hidden" name="helper_introLine" value="This individual would like to know more about your company."> <input type="hidden" name="helper_echoBlanks" value="true"> <input type="hidden" name="helper_sortOrder" value="firstname,lastname,emailaddress"> Last Name <input type="text" name="lastname" size="24" value=""><br> First Name <input type="text" name="firstname" size="18" value=""><br> E-Mail Address <input type="text" name="emailaddress" size="30" value="you@wherever.com"> <input type="submit" value="Send"></form>
Top

Miscellaneous

Templates | Large Forms | SPAM Protection | Database Integration | FormMemory | Miscellaneous