Make small changes to formmailer.php; upload formmailer.php and form.php to your webserver. Your website now has a secure mailform that hides all e-mail addresses from spambots!
View simple form and form code here.
Note: A more elaborate form containing radio buttons, checkboxes, file attachments, etc, can also be used. see FORM NOTES below for instructions and a sample form.
$tomail[0]="you@yourdomain.com";
you@yourdomain.com
to your e-mail address (with quotation marks)$mail_fields[0]="list,of,fields";
list,of,fields
to a comma delimited list of which fields you want in the resulting email and in the order you want them inNoteworthy comments:
action="formmailer.php"
). If you want to put your form page and formmailer.php in different directories, that's fine, just make sure the action value in the form tag still points to formmailer.php, for instance: <form id="form" method="post" action="scripts/mail/formmailer.php">
enctype="multipart/form-data"
must be added to the form tag.FormM@iler allows you to use custom error and success pages to link to via variables discussed further down in the document, however, if you choose to use the default error pages for the benefit of more specific errors messages and simplicity, you can also define exactly what the default messages are with the variable listed below:
Reopen the file formmailer.php and find the lines:$error_page_title
- The title of the error page.$error_page_text
- The text of the error page (in addition to the actual errors themselves).$thanks_page_title
- Title of the success page.$thanks_page_text
- The text of the success page.FormM@iler now supports any language that has a character set.
$charset[0]="UTF-8";
iso-8859-1 supports most standard ASCII single-byte languages for special double-byte languages, change this value to the approporiate charset for the language. FormM@iler defaults at UTF-8 which is unicode and hopefully works, by default with most any language.
You can have email sent to multiple recipients. In addition, you can send carbon copy (cc) email and blind carbon copy (bcc) email to multiple recipients. Just separate the addresses with commas.
Reopen the file formmailer.php and find the lines:
$tomail[0]="you@yourdomain.com";
$cc_tomail[0]="";
$bcc_tomail[0]="";
Designate more recipients by adding their email addresses separated by commas:
$tomail[0]="sales@aceplastics.com,admin@aceplastics.com,records@aceplastics.com";
$cc_tomail[0]="pres@aceplastics.com,sevice@aceplastics.com";
$bcc_tomail[0]="myhome@erthlink.com,myjunk@hotmail.com";
The last of the group above ($copy_from[0]="noreply@yourdomain.com")
is something different and should only have one email address, if any. That is explained under "COPY TO SENDER" below.
You can choose to have a copy of the email the visitor sends sent to the visitor also. Open formmailer.php and find the lines. (again, where the number inside [] matches the number of the config hidden field for that form).
The one limitation of email going back ot the sender is that you can not send any attached file back to the sender.
$send_copy[0]
, change the value to "yes"
to turn this feature on.$send_copy_format[0]
, sets the layout of the email. Options are "vert_table" or "horz_table", anything else will result in plain text email$send_copy_fields[0]
, has a comma-delimited list of the fields you want to include in the copied email, in the order you want them displayed.$copy_subject[0]
, enter the words you want to appear in the subject line of the email returned to the visitor.$copy_intro[0]
, is the custom intro text that appears at the top of the email body.$copy_from_email[0]
, indicates the email address of the sender of the copy.$copy_from_name[0]
, indicates the name of the sender of the copy.$copy_tomail_field[0]
, you want set the the name of the field which the user entered their email address.Option Name | Description |
$charset[0] | character set code for the email |
$tomail[0] | list of recipients |
$cc_tomail[0] | list of carbon-copied recipients |
$bcc_tomail[0] | list of blind carbon-copied recipients |
$subject[0] | the subject of the email to be sent |
$reply_to_field[0] | the name of the field that should be put in the "from" field of the email as the address the message is coming from. |
$reply_to_name[0] | the name of the field that should be put in the "from" field of the email as the name of the person or place the message is coming from. |
$required_fields[0] | a comma separated list of fieldnames you require to be filled in |
$required_email_fields[0] | a comma separated list of fields to be validated for valid email address syntax |
$attachment_fields[0] | comma delimited list of the fields of the form that are file attachment fields |
$return_ip[0] | do you want the IP of the sender returned with the email if available? yes/no |
$mail_intro[0] | header text for recipient email |
$mail_fields[0] | list of the fields of the form that you want sent to the recipient list, in the order you want them displayed |
$mail_type[0] | layout of email options are "horz_table" or "vert_table", anything else will result in a plain text email |
$mail_priority[0] | 1 is high, 3 is normal |
$send_copy[0] | whether to send a copy of the mail to the sender |
$send_copy_format[0] | layout of email sent back to sender options are "horz_table" or "vert_table", anything else will result in a plain text email |
$send_copy_fields[0] | which fields get included in the send_copy email |
$send_copy_attachment_fields[0] | comma delimited list of the fields of the form that are file attachment fields to be returned to the sender |
$copy_subject[0] | subject of sent copy |
$copy_intro[0] | Header text for autoresponder email |
$copy_from_email[0] | Email address the autoresponder comes from |
$copy_from_name[0] | Name the autoresponder comes from |
$copy_tomail_field[0] | field of email address to the sender for the sent copy |
$header[0] | absolute or relative path to a file you wish to include as a template header |
$footer[0] | absolute or relative path to a file you wish to include as a template footer |
$error_page[0] | the filename (and path if necessary) to a custom error page, if missing or blank default text in variable above will be used |
$thanks_page[0] | the filename (and path if necessary) to a custom thanks page, if missing or blank default text in variable above will be used |
DO NOT add the name of the attachment field to the $mail_fields
list.
Enter the file attachment field names in the $attchment_fields
variable as a comma-seperated list. To control the size allowed in the uploads add the hidden field <input type="hidden" name="MAX_FILE_SIZE" value="30000"> before the first field. This is a PHP function that will limit the size of the filed, the value being the maximum byte size allowed for any file attachment field.
Also note that if you plan to use the file attachment option enctype="multipart/form-data"
must be added to the form tag.
You can build your own form and formmailer.php will send it's contents in the email. A more elaborate sample called form2.php is provided. View form2.php, with radio buttons, checkboxes, dropdown box.
Also note that each form does not have to end in PHP, the form page itself can have any extension, but formmailer.php MUST retain it's php extension and the action of the form must point to it.
Note that any form field that could contain multiple selection, such as a multi-select dropdown menu, or checkboxes of the same name must end their name with brackets []
. This is a requirement of PHP so the PHP interpreter knows to expect the possiblity of several answers!
DO NOT use spaces in the field names of your form. A good option is to use an underscore ("_") instead.
The config hidden field may seem confusing, but it is done this way to prevent spambots from harvesting actual email addresses from hidden fields the way many scripts do.
It is possible to have a selectable recipient list by making your config field a select type form field like so:
<select name="config">
<option value="0">Sales</option>
<option value="1">Support</option>
<option value="2">Marketing</option>
</select>
which makes the config value variable upon the choice of the user.
This application is covered under the AGPL license.
As an addendum to the AGPL license, I also offer to the users of this script, the ability to purchase the right to remove the required links for the price of $20 per domain.
For those of you that want the quick and dirty version of this license and addendum it means the following:
See the license.txt file for further information.
Support is not promised with any of the freely used dB Masters' Scripts, however, there are forums at http://scripts.dbmasters.net/ where you may be able to find help.