Mail2Friend, is a form-to-email gateway that allows your website's
visitors to easily email a friend or associate the URL of a page on
Rather than going through the additional steps of opening their mail client to compose a new message, then copying and pasting the URL from the browser to the message, with a simple click your site's visitor can send the URL to a specified email address from within your site and continue browsing with minimal disruption.
Mail2friend is installed from the Package Installer section of your netConsole. Select "mail2friend" from the drop-down menu and click the install button.
Setting Up Mail2friend
When the mail2friend script is installed, a new server-parsed HTML file, mail2friend.shtml, is dropped into your webshare directory. This document contains the form visitors will use to send your page's URL to their friend.
The default form page lacks any real formatting and can be edited to match the look of your site. We recommend you employ a simple ASCII editor such as Notepad (WinOS), SimpleText (MacOS) or Vi/VIM (Unix). The reason for this is many WYSIWYG (What You See Is What You Get) editors (e.g. Adobe GoLive, Macromedia Dreamweaver, Microsoft FrontPage, etc.) will alter the code that the script requires to function.
Linking to the FormTo say that the pages link to the mail2friend form is actually a misnomer. The pages will not contain a direct hyperlink to the form, but rather, the hyperlink syntax should look like this:
<a href="page-to-be-mailed.html$MAILPAGE$">Email This Page to a Friend</a>
By using Apache's rewrite engine, any requests for pages with the $MAILPAGE$ text on the end will be seamlessly redirected to the mail2friend form.
There are two configuration options for the mail2friend script.
Changing the Form Document
The first option allows you to change the name of the form visitors are directed to. By default, the form is called mail2friend.shtml. To change the name of the form, go to the package's configuration page by clicking on the "mail2friend" link on the main Packages page of your netConsole. On the configuration page that follows you may change the name of the form as shown below:
Note: If you specify another form page, please either rename the default form page or use it as a template to build a new one. The reason behind this is the form tag:
<form method="POST" action="/cgi-bin/mail2friend">
the SSI tag executing mail2friend.pl:
<!--#exec cgi="/cgi-bin/mail2friend" -->
and the names of the form elements:
<input type="text" name="recip_name">
<input type="text" name="recip_email">
<input type="text" name="sender_name">
<input type="text" name="sender_email">
all must be preserved in order for the form to work.
The other configurable element of the mail2friend script is what page your visitors are redirected to when they complete the form:
<input type="hidden" name="redirect" value="<!--#echo var="PATH_INFO" -->">
With an unmodified script, there's really no need to alter the redirect page. Your visitor will click on the link, fill out the form, submit, and return to the page.
However, if you do modify the behavior of the script, i.e. cause the form to be opened in a new window, you will most likely want to redirect your visitors to some other page.
Please note that the value of the hidden redirect form field must be relative to your base URL. For example, if the redirect is to be at http://your-domain-name.com/path/to/redirect.html the form field would look like this:
<input type="hidden" name="redirect" value="/path/to/redirect.html">
These will not work:
<input type="hidden" name="redirect" value="path/to/redirect.html">
<input type="hidden" name="redirect" value="http://your-domain-name.com/path/to/redirect.html">
There are a number of ways to change the way mail2friend works:
Changing Message Subject and Body Text
To change the subject or body of the form-generated message, first either download the script from the cgi-bin, or open a terminal connection to your account on the server. Then, open the script in your favorite ASCII editor or in Vi on the server.
The section of the script you will want to edit lies on lines 46 and 50-56. The script features commented instructions to assist you in your editing:
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
################################################################### ## Instructions for editing the subject and body of the message. ## ## There are a few variables you can use in your subject and body: ## $sender_name, $sender_email, recip_name, recip_email, $domain, ## and $url. ## ## Edit the subject of the form-generated message here: ##
Once you're done editing, save your changes. If you downloaded the script and edited it locally, you must now upload it in ASCII format and ensure that the permissions (755) remain intact.
If you do this, you will probably want to specify the URL to the page you want the visitor to be redirected to after submitting the form. See the Redirect Page section of Configuration Options for more information on this.
Use SSI to Make Mail2friend More Dynamic
You can dynamically include the current page into your hyperlink with SSI (Server-side Includes). This is very handy if your site uses SSI to include navigation onto each page and you want the navigation to feature an "Email this page to a friend" hyperlink.
<a href="<!--#echo var="DOCUMENT_URI" -->$MAILPAGE$">Email this page to a friend</a>
- IC Tech. Ref. Document: Server Side Includes (SSI)