Chapter 9: Email
Enabling the Send an Entry Functionality
Problem
You want to give readers the option of sending an entry to someone else via email.
Solution
Place a send entry form in your layout.
Discussion
Movable Type ships with a script called mt-send-entry.cgi. This script can be used to implement a simple "mail this entry" form that allows visitors to email links to entries.
To add this feature to a site, insert an HTML form that POSTs to the mt-send-entry.cgi script in your MT home directory with parameters of entry_id, to, from, message and _redirect. entry_id and _redirect should be hidden fields that are assigned values when the page is built. _redirect is the URL to send the submitter once the message has been sent.
Here is a generic form that could be used in an Individual Archive template to implement a mail-this-entry feature:
<form method="post" action="<$MTCGIPath$>mt-send-entry.cgi">
<input type="hidden" name="entry_id" value="<$MTEntryID$>" />
<input type="hidden" name="_redirect" value="<$MTEntryLink archive_type="Individual"$>" />
Email this entry to:<br />
<input name="to" size="20" /><br /><br />
Your email address:<br />
<input name="from" size="20" /><br /><br />
Message (optional):<br />
<textarea name="message" rows="5" cols="20" wrap="virtual"></textarea><br /><br />
<input type="submit" value="Send" />
</form>
This form could use to be refactored. labels, ids etc. which I can do however what about localization?
When a visitor fills out the form and presses the Send button, mt-send-entry.cgi checks that the required parameters have been submitted (all but message are required), checks if the to and from email addresses look valid, loads the entry by its ID, and sends a message using a simple internal template. This template includes the sender's message (if any), the title of the entry and its permalink.



