Custom Form Mail

FormMail is a very popular tool to capture information in a simple form and send this to an email address. It is relatively easy to set up and does its job well. However, spammers have found security holes in previous versions, allowing exploitation of email accounts on the host server.

Note: FormMail is not available on Windows servers. Use the Windows section of the following article for Windows servers:

HostGator recommends using the standard "server-wide" FormMail script described below whenever possible.


The following tutorial provides the code for a default FormMail script. Please select the link above to toggle the text.

Server-Wide FormMail

HostGator suggests that you use the above FormMail script whenever possible. This "server-wide" script ensures that you will not be held accountable if there are any exploits found on this version of FormMail.

Server-wide FormMail Considerations

There are a few points to keep in mind when using the server-wide FormMail script:

  • Make sure you use an email address on your HostGator server. For security reasons you may not use an outside email address. However, you can always use a mail fetching service to send the information on to an outside email address.
  • The server-wide FormMail option does not work with reCAPTCHA, as you cannot edit the server-wide script.
reCAPTCHA is a Google service which lets you embed a CAPTCHA in your web pages in order to protect them against spam. This article from Google has more information:

Custom FormMail Scripts

If you have a customized FormMail script you wish to use, including those created with third-party form generators, please make sure that it complies with our Terms of Service and Acceptable Use Policy.

Note: HostGator cannot support third-party scripts. For assistance with unique scripting requirements, site customization or website design, please contact our HostGator Design Services for a quote.