mass email
Posted: Sat Nov 29, 2003 5:41 pm
im a newb, so be gentle. ok, what i need to do is created a page like 'admin.php' where i type something into a textarea and it sends to all the emails in a column in a mysql DB. I have a script, but it does not actually send the emails out, so i am baffled. Help me out and tell me what I have to do.
Code: Select all
<form method="post" action="<?php echo $PHP_SELF?>">
<p><textarea rows="7" name="tidbit" cols="38"></textarea></p>
<p> </p>
<p><input type="submit" value="submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
<?
if ($submit) {
mysql_connect("localhost","----","----") or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("-----rs") or die ("Unable to select requested database.");
$result = mysql_query("SELECT email FROM members")
or die("Invalid query: " . mysql_error());
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$to .= $line['email'].",";
}
$to = substr($to, 0, -1);
$subject = "Your weekly TidBit";
$message = $tidbit;
$headers = "From: webmaster@tidbitfacts.com";
mail($to, $subject, $message, $headers);
} ?>