Autoresponders are mechanisms that automatically email a message to a user when a certain event is completed. Usually, this would be when a new user signs into the list by using a form. To edit the autoresponder, a technique similar to what we used to edit addresses will be used:
autoresponder.php3
<html><head><title>Edit Maillist addresses</title></head><body>
<form method=post action="writeautoresponder.php3">
<br>
This is the automatic message sent to people who submit
their name to the Test List mailing list. See Page 5 in the
tutorial to see an example of using this feature.
<br><br>
<textarea cols=70 rows=20 name="Body">
<? readfile("data/autoresponder.txt"); ?>
</textarea>
<br><br>
<input type="submit" name="submit" value="Save This List"></FORM>
<br><br><a href="addnames.php3">Add names to a list</a>.
<br><br><a href="data/log.txt">View Send Log</a>.
<br>
</body></html>
And then the form saves our
changes:
writeautoreponder.php3
<html><head><title>Updating file....</title></head><body>
<br><br>
<b>The following autoresponder message has been saved:</b><br>
<?
$myfile = fopen("data/autoresponder.txt","w");
fputs($myfile,$Body);
fclose($myfile);
?>
<br>
<pre><? echo $Body ?> </pre><br>
<br>
<a href="index.php3">Home.</a>
</body></html>
To activate it, create a code snipet which will put a small
form on any page you choose. Something similar to this would work anywhere:
<b>Get notified of updates by email:</b><br>
<form method="post" action="thanks.php3">
<input type="text" name="Email" size="20">
<input type="submit" Value="Subscribe"></form>
All that’s left is a processing and Thank You page, which
borrows code from the other pages made earlier:
Note line 4 – it’s a lightly documented trick that allows you
to read an entire file into a variable, which is exactly what we need to do here. Of course, if you use this script yourself, it will probably be in another directory, so watch your paths. Also note this is just for one list – what would you need to do to make multiple autoresponders?
And that’s it! Now your new members will immediately receive a welcome message, or be sent important info, receive a joke of the day, or whatever else you can dream up!