You are here: emailing MySQL list not working « PHP « IT news, forums, messages
emailing MySQL list not working

Posted by Bruce Gilbert on 11/12/05 05:33

Hello,

I am using a template for an email database. This has a MySQL database
where the end user can sign up to receive my email newsletter, They
subscribe and are entered into a MySQL database that I have set up.
Everything works fine as far as being entered into the dataase The
problem occurs when I send a test email to the database list. (I am
sending one to myself). The email never gets sent!

the code to send out the email from the MySQL database list is as follows:

<?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";
$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;
?>

The form is located here:

http://www.inspired-evolution.com/sendmailform.php

let me know if I need to provide any more information.

Thanks!

Bruce Gilbert

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация