INTERMEDIATE
Start
Where your files are
To chmod or not to chmod
Tripod's Modules
>>Tripod's mail program
Limitations
Main Menu
|
CGI is frequently used for e-mailing purposes, whether it be a site manager sending e-mail to visitors or information compiled from a site's forms being mailed to the
site's owner. In order to do either task, a script needs access to an e-mail program. Tripod has provided its users with a module called TripodMail.pm. To get that
module, you'll need to load it into your cgi-bin here. However, Tripod's mail module doesn't function exactly like the mail programs you may
have used before.
You need to have a mail template in your directory which contains the normal fields, such as "To," "From," and "Subject." You can include variables in that template.
There is a method of the TripodMail.pm module called "sendMail". This method needs two bits of information: the name of the mail template in your directory, and a hash
of variables. These are the same variables that are referred to in your template. Say you had a template that looked a bit like this:
To: $recipient
From: $sender
Subject: $subject
$body
$signature
You could then use the TripodMail module to send e-mail by creating a new instance:
require TripodMail;
$mail= new TripodMail;
$mail->sendMail($template, /%hash);
In this case, "$template" is the name of the template file, and "%hash" is a hash of variable mentioned in the template. The hash for the template about should include
a recipient, sender, subject, body, and signature in the hash of variables. That hash would be built elsewhere in the script that's calling the TripodMail module. For
example, if this bit of code were in a guestbook script, that script would collect information from a form (the place a visitor actually signed the book). Along with
building a new entry in your guestbook, the script would also store the visitor's e-mail address in your hash as "recipient," and your e-mail address as "sender."
One important thing to note is that TripodMail is not the same thing as a mail program; any ready-made script that uses a mail program will have to be significantly
altered before it will work. If you're writing your own scripts, keep this information in mind if you plan to use TripodMail. The TripodMail.pm module also includes
information about how it works and how to call the methods.
|