Developing the Mailing Mechanism

With the subscription mechanism in place, you can create a basic form interface for a script that will take the contents of your form and send it to every address in your subscribers table. This is another one of those all-in-one scripts, called sendmymail.php, and it is shown in Listing 17.2.

Listing 17.2. Send Mail to Your List of Subscribers
 1: <?php 2: if ($_POST[op] != "send") { 3: //haven't seen the form, so show it 4: print " 5: <HTML> 6: <HEAD> 7: <TITLE>Send a Newsletter</TITLE> 8: </HEAD> 9: <BODY> 10: <h1>Send a Newsletter</h1> 11: <form method=\"post\" action=\"$_SERVER[PHP_SELF]\"> 12: <P><strong>Subject:</strong><br> 13: <input type=\"text\" name=\"subject\" size=30></p> 14: <P><strong>Mail Body:</strong><br> ...

Get Sams Teach Yourself PHP, MySQL® and Apache All in One now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.