Using a mailto form on your web page

These instructions will guide you through including a mailto form on web pages hosted with SpiritOne.

  1. Download the script

    Download the mailto.pl script from http://www.aracnet.com/~webmaster/scripts/mailto.pl . You may either click on the link then, when the script has loaded completely into your browser, save it to your computer. Or, just right-click on the link and choose Save As...

  2. Edit the mailto.pl script

    Tell the mailto.pl script who can receive mail. This step is one of the most critical, as the mailto script will only send email to addresses in the script itself. This is so spammers cannot hijack scripts on our server to send spam.

    Open the script in a text editor. Important! If you are a Windows user, use Wordpad instead of Notepad. Notepad (and MS Word) inserts invisible Windows-only characters into the script that will prevent the script from functioning correctly.

    Once the script is open, look for the following:

    # Here is where the email recipients are listed
    my @valid_rcpts = (
    'nobody@spiritone.com',
    'nobody@aracnet.com',
    );

    Replace either, or both, of the sample addresses with the email address you will be sending messages to using this script. Additional email addresses may be added as necessary, but be careful to use the same format. The email address must be enclosed in single quotes, and addresses must be separated by commas.

    Multiple form recipients:

    The mailto.pl script is very picky about its recipients. If sending a form to multiple addresses, the addresses entered in this step must be exactly like the addresses are specified in the HTML code of the form.

    Thus, if you were going to send a message to john@domain.com, tom@domain.com, and harry@domain.com, you would use this HTML to specify this (more on this step below):

    <input type="hidden" name="to" value="john@domain.com, tom@domain.com,harry@domain.com">

    The edited portion of the mailto.pl script would need to look like this:

    my @valid_rcpts = (
    'john@domain.com, tom@domain.com,harry@domain.com',
    'nobody@aracnet.com',
    );

    Notice that the spaces after commas are consistent between the two. This is critical. If the spaces are different, or even the capitalization is different, the script will not work. Also, all of the addresses are enclosed in one set of single brackets.

  3. Upload the script.

    Economy and Personal Web Hosting only: Using an FTP program, upload the script into the cgi directory within your public_html directory. If you do not currently have a cgi directory inside of your public_html directory, email us at Support@SpiritOne.com and our Support staff will create a CGI directory for you. If a CGI directory does not exist, creating one yourself will not work.

    Enhanced Web Hosting: Using an FTP program, upload the script into the mainwebsite_cgi directory.

  4. Tell your web page to use the script.

    For purposes of these instructions, all variables will be passed to the script using hidden input fields. In practice, any of these fields can be populated by visible input fields using the same 'name' attributes. For example, if you wanted to allow visitors to specify their own subject line, you could allow that to be specified through a 'select' list or a regular text-entry box. To see this in action, look at the source of our Contact Page.

    ID's and classes may be used freely with any of the input or form elements without impacting the script.

    All of the following must be present in a form using this script:

    The Form tag:

    <form action="/cgi-bin/mailto.pl" method="post">

    The "action" line will be different if you are using this script on a personal web site (i.e. one using a domain name not owned by you), the line should be changed to:

    <form action="/cgi-usr/your username/mailto.pl" method="post">

    Substitute your SpiritOne username in place of "your username" above.

    Destination address:

    This is where form submissions will be sent:

    <input type="hidden" name="to" value="destination email address">

    Sender address:

    This is the email address that will appear as the sender of the email generated by the form

    <input type="hidden" name="from" value="an email address">

    Subject line:

    This will be the subject of emails generated by your form:

    <input type="hidden" name="subject" value="Subject goes here">

    Body:

    This will appear in the body of all emails generated by the form:

    <input type="hidden" name="body" value="This email is from the web page">

    Nexturl

    This is the URL of the page visitors will see after they submit the form. This should be an absolute URL. Relative URLs are relative to the script's location, not the location of the form.

    <input type="hidden" name="nexturl" value="http://www.spiritone.com/yourthankspage.com">
  5. That's it! Upload your form and test it. If you are taken to the URL specified as the 'nexturl', then the form is working.

If you have any additional questions about using this mailto.pl script on your web page, please send an email to webmaster@SpiritOne.com.

What are People Saying about SpiritOne?

"Real people in the community with a real business. I have the confidence they will be here when I need them."