Location: PHPKode > projects > The Community Wish List Server > wlserver/admin/allmail.php
<?php
    if ($mailAction == 1) {
        $to = "";
        
        // Retrieve all e-mail addresses
        include ("../php/dbconnect.php");
        $recipientListQuery = "select emailaddress from person where emailaddress != ''";
        $addresses = mysql_query($recipientListQuery);
        if (!$addresses) {
            die("Could not retrieve e-mail addresses: allmail.php<br>".mysql_error());
        }
        $numAddresses = mysql_num_rows($addresses);
        print "<html>";
        print "<body>";
        print "<p>$to</p>";
        print "<p>$subject</p>";
    
        for ($addressCounter = 0; $addressCounter < $numAddresses; $addressCounter++) {
            $to = mysql_result($addresses,$addressCounter,"emailaddress");
            print "$to<br>";
            mail($to,$subject,$message,"From: hide@address.com\r\n"."Reply-To: hide@address.com\r\n");
        }
        ?>
        <p>Mail has been sent.</p><p><a href="../index.php">Back to wish list</a></p></body>
        </html>
        <?php
    } else {
        ?>
        <html>
            <head>
                <title>Send an e-mail to everyone in the wish list!</title>
            </head>
            <body>
                <form name="mailform" method="post" action="allmail.php">
                <p>Subject: <input name="subject" type="text" size="50" maxlength="128" name="subject"></p>
                <p>Message:<br>
                <textarea name="message" rows="10" cols="50" wrap="virtual"></textarea>
                </p>

                <input type="hidden" value="1" name="mailAction">
                <input type="submit" value="submit">
                <input type="reset" value="clear">
                </form>
            </body>
        </html>
        <?php
    }

?>

Return current item: The Community Wish List Server