Using mailargs, mailbody

These commands let you process data from the Web as email. Like echo and log, the data sources for the mailargs can be the built-in environment variables, HTTP Headers and Forms Data. The mailbody command has the additional capability of supporting the NetScape "File Upload" forms button.

Samples demonstrating the mail commands are found in /Samples/mail-forms/.

The mail commands are dependent upon using Mail Server and User Manager along with the Web Server. When a mail command runs, the Web Server spools the message into Mail Server's Mailbox as a MIME message in RFC822 format.

 


 

mailargs

You can use this for page access notification and automatic "thank you" notes. The mailargs command accepts a variable number of parameters to form the message headers and content. #mailargs works like the #log command, except that some params are used to address the message, and the rest create its content.

This sample uses the LOCATION and REFERER environment variables to automatically notify the site's Web Master about bad links.

 

Example:

<!-- #mailargs "webmaster" " " "link error"

"A Not Found error occurred serving: " LOCATION "

this page was linked to from: " REFERER -->

 

The first is parameter the mailto address. It can be a string, or a variable from a form. If no domain name is provided in the address, mail server will deliver it to the local host.

The second is the mailfrom address. It can be a string, or a variable from a form. In this sample the return address is empty since its an error message from a web page.

The third is the subject of the message. It can be a string, or a variable from a form.

The fourth and subsequent parameters form the body of the message using the LOCATION and REFERER variables and other strings.


 

mailbody

The mailbody command is used to process the "multipart/form-data" generated when using the NetScape "file" input type in a form. 

When using multipart/form-data TeleFinder cannot process individual Form fields as variables, so the mailbody parameters need to come from strings , HTTP headers or the environment variables. The forms variables will show up in the content of the mail message as "Form Name=data."

mailbody takes three (3) named parameters: addr, subj and from, to form the message's to address, subject and from address.

The mailbody command must be in an Active Page that is the target of a Post command. This is accomplished by creating a HTML form in a page ( not necessarily an Active Page ) that specifies an Active Page as it's ACTION.

Begin the form with a form tag as follows:

<FORM ACTION="upload.spml" METHOD="POST" ENCTYPE="multipart/form-data">

In the FORM's ACTION parameter substitute the name of your page for "upload.spml." The ENCTYPE and METHOD must be as shown here. The full sample can be found in /Samples/mail-forms/homepage.html and /Samples/mail-forms/upload.spml.

In the actual HTML form, you need to add the NetScape "file" input button.

 

<INPUT TYPE=FILE VALUE="Browse" NAME="attachment" >

NetScape's FILE Input Type only supports the "data fork" of Macintosh files so they must be converted into a data only file before uploading. Converting the file to BinHex format using Aladdin System's StuffIt Expander is a good way to convert Macintosh files to BinHex format.

DOS, Windows and UNIX files are all single fork, and do not need converting.

In the Form's Action page use the #mailbody command as shown here.

<!-- #mailbody addr="sysop" subj="LOCATION"

from="webserver" -->

In this example the file attachment and forms data will be delivered to "sysop" at the local host. The Subject field will be filled in with the page's location. The From header of the message will contain "webserver."