[thelist] form that sends to emailing list stores in MySQL table not working
Bruce Gilbert
webguync at gmail.com
Sun Nov 13 20:03:31 CST 2005
I have set up a form where you can enter your email address and
confirm to be entered into a MySQL table database.
this part works fine, but when I try to send a sample email to the
list, nothing comes through. I was hoping somone could take a look at
my code and see if they might know what is going wrong.
// here is the form to send to the list
<form id="mailinglist" method="post" action="sendmailinglist.php">
<fieldset >
<legend>Inspired-Evolution.com Nation Mailing List</legend>
<table class="mailinglist" summary="sends email newsletter out to
Inspired-Evolution.com Nation">
<tr>
<td>
<label for="subject">Subject of email:</label> </td>
<td> <input type="text" id="subject" name="subject"
value="<?=$subject ?>" maxlength="200" size="25" />
</td>
</tr>
<tr>
<td>
<label for="message">Type The Message Here:</label>
</td>
<td> <textarea name="message" id="message" value="<?=$message ?>
cols="" rows=""></textarea>
</td>
</tr>
<tr>
<td> </td>
<td align="right">
<input class="submit" src="/images/submit.gif" alt="Submit"
type="image" name="submit" value="submit" />
</td>
</tr>
</table>
</fieldset>
</form>
// code which is supposed to send to MySQL list
<?php
include("config.php");
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];
$sender = "Bruce Gilbert <webguync at gmail.com>\n"; //put your name and
sending address here
$reply_to = "<webguync at gmail.com>\n"; //reply-to, insert your address
here, might not be supported by your server
$return_path = "webguync at gmail.com\n"; // return-path, if you have
one, also might not be supported by your server
$x_sender = "<webguync at gmail.com>\n"; //your address, another setting
possibly not supported by your server
$message .= "\n\n This is a double opt-in mailing list. All recipients
have confirmed their subscription. If you no longer wish to receive
these emails, please go to http://http:www/inspired-evolution.com \n
";
$query = "
SELECT
*
FROM
mailinglist
WHERE
subscribe=1
AND
confirmed=1";
$result = mysql_query($query);
while ( $row = mysql_fetch_array($result))
{
$rec_id = $row["rec_id"];
$email = $row["email"];
$recipient = $email;
$headers = "From: $sender";
$headers .= "Reply-To: $reply_to";
$headers .= "Return-Path: $return_path";
$headers .= "X-Sender: $x_sender";
$headers .= "X-Mailer: PHP4\n"; //mailer
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Mime-Version:1.0\n Content-Type: text/plain;
charset=\"iso-8859-1\nContent-Transfer-Encoding: 8bit\n";
mail( $recipient, $subject, stripslashes($message), $headers );
sleep(1);
}
// run second query to automatically dump unsubscribed email addresses.
$query2 = "
DELETE FROM
mailinglist
WHERE
subscribe='0'
AND
confirmed='0' ";
//run the query
mysql_query($query2, $link) or die (mysql_error());
mysql_close();
header("location: mailsent.php");
exit;
?>
More information about the thelist
mailing list