PHP
  Home arrow PHP arrow Page 5 - Creating a Mailing List Manager with P...
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Creating a Mailing List Manager with PHP
By: Duncan Lamb
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 39
    1999-12-16

    Table of Contents:
  • Creating a Mailing List Manager with PHP
  • Creating the front page
  • Adding names to the list
  • Editing the names
  • Autoresponders
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Creating a Mailing List Manager with PHP - Autoresponders


    (Page 5 of 6 )


    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:

    thanks.php3

    <html><head><title>Thanks!</title></head><body> <? $Body = readfile("data/autoresponder.txt"); mail("$Email","Welcome to my mailing list!", "$Body","From: Me\nReply-To: me@myaddress.com"); $myfile = file("data/mylist.lst"); $fh = fopen("data/mylist.lst","w"); for ($index=0; $index < count($myfile); $index++) { if ($Email != chop($myfile[$index])) {fputs($fh,$myfile[$index]);} } fputs($fh,$Email."\n"); fclose($myfile); ?> Thank you! <br><br> <a href="index.php3">Home</a>. </body></html>
    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!

    More PHP Articles
    More By Duncan Lamb


       · The code have lot of little mistakes.
       · No it doesn't whoever posted that comment above needs to get a clue.
     

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT