« Creating an Additional Weblog | Main | How to Make a Pop-up Window »

Email to a Friend

The last version of MT that included a Send Entry script was MT 3.15. MT no longer includes such a script. Therefore this tutorial is out-of-date and not useful to users of more recent MT versions. ~Elise Feb 22, 2007

Movable Type comes with a built-in capability for allowing your weblog visitors to easily send an email with a link to your entry by filling out a simple form. The one small catch is that spammers can take advantage of cgi email programs like this to send out spam. Ben Trott has made a few adjustments to the MT code in the most recent releases to help protect against these types of spammers. But the easiest way to take advantage of this useful utility while at the same time protecting yourself is to change the name of the mt-send-entry.cgi script. The following are instructions on how to include Email to a Friend on your MT weblog, first starting with changing the name of the script.

1. Change the name of the mt-send-entry.cgi script. In your CGI bin change the name of this file to something else, also ending with the .cgi suffix. For example, mt-send-an-email.cgi (use something else - a unique name).

2. Copy the Send Entry form into your Individual Entry Archive template. Change the name of the cgi file in the first line of the code to reflect the new name of your Send Email cgi. Example:

<form method="post" action="<$MTCGIPath$>mt-send-an-email.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" />

Place the code on your Individual Entry Archive template where you would like the form to be. If you place it in the main body and not in the sidebar, you may want to expand the column size in the message window from "20" to something greater, like "45".

Nest the code in the appropriate style div tags for your site. For example, on this site, I put the email form underneath the comments section. I want the email heading to look just like the comments heading which, in MT3, uses <h2></h2> tags.

<h2>Email to a friend</h2>

For default MT2.661, the heading tag would look like so:

<div class="comments-head">Email to a friend</div>
<div class="comments-body">

In the case of MT2.661, after the Send Entry code I insert a closing div tag.

3. Link to the Send Entry form. You may want to place a link in the Posted To line (at the end of each entry) directing readers to the form. To do this, first place an anchor tag right before the form, like so for MT3:

<a name="email"></a><h2>Email to a friend</h2>

or like so for MT2.661:

<a name="email"><div class="comments-head">Email to a friend</div> <div class="comments-body">

Then place a link on your Posted To line. On the Individual Entry Archive template the link would look like this:

<a href="#email">Email to a friend</a>

On the Main Index template, the link would look like this:

<a href="<$MTEntryPermalink$>#email">Email to a friend</a>

That's it! Save and rebuild your site.

MT-Mail-Entry - a plugin for emailing the entire entry, not just a link, includes a popup email form.

Comments (2)


Hi there, this is a very detail instruction, thanks.

Just a question, is there any way to include multiple email addresses in the field in "Email this entry to:", I would like to send a particular post to more than 1 email addresses, can that be done?

Hi ML,
I've noticed since the Ben Trott adjusted the code so it would be less likely to be abused by spammers that you can't send to multiple addresses anymore.