form not submitting to MySQL list
Posted: Sat Nov 12, 2005 5:01 pm
I am trying to set up a form which emails to a list of people who have been entered into a MYSQL database. Everything works perfect as far as being registered into the database except when I send out a sample form to members in that database (right now me), it doesn't want to send. (Don't get an email even though no errors occur and I am sent to the confirmation screen.
the code for so send to the list of emails is:
the form can be found here:
http://www.inspired-evolution.com/sendmailform.php
the code for so send to the list of emails is:
Code: Select all
<?php
// this script is used to as the action for the form on sendmailform.php
// it sends the email to all persons who have subscribed to the mailinglist and confirmed their subscription
//include the config file
include("config.php");
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];
//Variables for the headers
// customize this stuff
$sender = "Bruce Gilbert <webguync@gmail.com>\n"; //put your name and sending address here
$reply_to = "<webguync@gmail.com>\n"; //reply-to, insert your address here, might not be supported by your server
$return_path = "webguync@gmail.com\n"; // return-path, if you have one, also might not be supported by your server
$x_sender = "<webguync@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://$list_owner_domain_name \n
Get this custom mailing list system for your site. Go to http://www.karlcore.com for more info! \n";
// this selects the table and orders the results by the name
// it only selects the listings that have been confirmed
$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\r\n";
$headers .= "Reply-To: $reply_to\r\n";
$headers .= "Return-Path: $return_path\r\n";
$headers .= "X-Sender: $x_sender\r\n";
$headers .= "X-Mailer: PHP4\r\n"; //mailer
$headers .= "X-Priority: 3\r\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;
?>http://www.inspired-evolution.com/sendmailform.php