I am tring to create my own mailing list. I want to be able to store the email addresses in a MySQL table, retrieve them, and enter a message in a web form, and have the email sent to the multiple users. I have included the codes I have been working with. Thanks for any help you can give!
Kevin Muller
////code for mail_list.php/////
<?
$db_name = "thejuggalos";
$table_name = "mail_list";
$connection = @mysql_connect("localhost", "account", "password") or die("Error 1");
$db = @mysql_select_db($db_name, $connection) or die("Error 2");
$sql = "SELECT email FROM $table_name";
$result = @($sql, $connection) or die("Error 3");
while ($row = mysql_fetch_array($result)) {
$email = $row['email'];
;
$result1 .= "
$email";
}
?>
<head>
<style type="text/css">
a:hover {color:white}
a {text-decoration:none}
</style>
<title>JuggaloDirectory.com</title>
</head>
<body>
<form method="post" action="send_list.php">
<b>Email To:</b><br>
<textarea cols=30 rows=5 name="juggalos" size=30><? echo "$result1"; ?></textarea>
<br><br>
<b>Message:</b>
<br><textarea name="message" cols=30 rows=5 wrap=virtual></textarea>
<br><br>
<input type="submit" name="submit" value="Send This Form">
</form>
</body>
////code for send_list.php/////
<?
/ recipients /
$recipient .= "$juggalos" . ", " ;
$subject .= "TheJuggalos.com Mailing";
/ additional header pieces for errors, From cc's, bcc's, etc /
$headers .= "From: WeBmAsTa <juggalo_wicked@hotmail.com>\n";
$headers .= "X-Sender: <birthday@php.net>\n";
$headers .= "X-Mailer: PHP\n"; // mailer
$headers .= "X-Priority: 1\n"; // Urgent message!
$headers .= "Return-Path: <birthday@php.net>\n"; // Return path for errors
/ If you want to send html mail, uncomment the following line /
// $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
$headers .= "cc:admin@juggalodirectory.com\n"; // CC to
$headers .= "bcc:juggalo_wicked@yahoo.com, birthdaygifts@php.net\n"; // BCCs to
/ and now mail it /
mail($recipient, $subject, $message, $headers);
?>
<BODY>
The emails have been sent!
</body>