im working on a modifying a mailing list that i found, that will allow me to send email to certain addresses located in a access database.
I dont get any error, but I am not receiving the email. i setup myself in the database, residing in a state that no one else is from, so i can test mail to myself.
heres the code:
<?php
include("dbconnection.php");
if (!isset($_POST['submit'])):
?>
<html>
<head>
</head>
<body>
<?php require_once("adminOnly.php");?>
//theres more html here, but no need to paste it in
</body>
</html>
<?php else:
ini_set(SMTP, "mail.sliquid.com");
ini_set(smtp_port, 25);
ini_set(sendmail_from, "info@sliquid.com");
$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$state = $_POST['state'];
if ("all" == $to) {
$x = 1;
$hold = 50; // quantity of emails sent before 3 sec delay
$emails ="SELECT email FROM customers";
while ($sendemail = odbc_exec($cnx,$emails)) {
$email = $sendemail["email"];
mail($email, $subject, $message, "From:Sliquid Email List <info@sliquid.com>");
$x++;
if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
sleep(3);
$x = 0;
}
} // end of while loop
}
else {
$bycountry ="SELECT email FROM customers WHERE state = '$state'";
while ($statemail = odbc_exec($cnx,$bycountry)) {
$email = $statemail["email"];
$okemail = mail($email, $subject, $message, "From:Sliquid Email List <info@sliquid.com>");
$x++;
if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
sleep(3);
$x = 0;
}
} // end of while loop
}
?>
<html>
<head>
</head>
<body>
SUCCESS! You will be redirected.
<?php
header("Refresh: 3; URL=http://www.sliquid.com/protected/admin.php");
echo " "; // NN4 requires that we output something...
exit();
?>
</body>
</html>
<?php endif; ?>
also, heres my dbconnection.php
<?php
$cnx = odbc_connect( 'records_db' , 'Admin', '******' );
if (!$cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}
?>
also, the ini_set stuff is from another page i have that emails properly, but i dont know if i need it for this script.