Mailto.pl

From Daily Data

Jump to: navigation, search

Documentation for mailto.pl

The mailto.pl CGI script can be used to either allow visitors to send e-mail to you from a web page, or can send the information from a form you have created to one or more e-mail accounts of your choosing.

In order to use mailto.pl, a file named mail.list must exist in the same directory as your copy of the script. This file contains a list of aliases and the real e-mail addresses, one alias per line. Example:

prez:MrPresident@whitehouse.gov
congress:texas@congress.gov,alabama@congress.gov,oregon@whitehouse.gov
war:pentagon@navy.mil

In the above example, three aliases (nicknames) are given, one of which (congress) goes to multiple recipients.

You can call this CGI Script in one of two ways:

  • Call it direct
    • This will generate an email form for the person named in 'nickname', and if they exist in the 'mail.list' file. If no 'nickname' is specified in the QUERY_STRING when the script is first invoked, or the nickname cannot be found in the 'mail.list', an email form with a SELECT box of all valid nicknames is generated. When the email form is submitted, it will call itself via method of POST, and send the email to the recipient, outputting a confirmation message. If the HTTP_REFERER was trasmitted when the script was first invoked, there will be a hyperlink available to go back to that page (such as the user's home page).
    • Example <A HREF="/cgi-bin/mail?nickname">
  • Post information from a form
    • This will forward the results from the FORM, which can exist anywhere, to the recipient specified by 'nickname'. Since the 'nickname' is in the QUERY_STRING, the FORM *must* use the METHOD="POST", otherwise the recipient's nickname will be blown away.
    • Example: <FORM METHOD="POST" ACTION="/cgi-bin/mail?nickname">
    • If used within a form, the following additional tags may be used
      • <INPUT TYPE="hidden" NAME="next-url" VALUE="/~user/received.html">
        If this is present in the FORM input, the client will be redirected to this HTML file as a confirmation message instead of the default.
      • <INPUT TYPE="hidden" NAME="subject" VALUE="My survey results">
        <INPUT TYPE="hidden" NAME="from-name" VALUE="Average Web user">
        <INPUT TYPE="hidden" NAME="from-email" VALUE="jdoe@domain.com">
        These values will then be used in the header of the email message for subject and from. If not specified, default values will be substituted.
      • <INPUT TYPE="hidden" NAME="me-too" value="Y" >
        This will cause the sender to receive a copy of the e-mail if they entered a valid e-mail address (i.e. the value of from-email is not blank). Note, no validity check is made, on the e-mail address, so if they did not enter it correctly, it will simply cause an error message in the system log.
      • <INPUT TYPE="hidden" NAME="next-after_confirmation" value="SOME_URL">
        This will cause the confirmation page to appear with a link back to SOME_URL. Note that this and next-url are mutually exclusive (next-url wins if both are included).