PDA

View Full Version : phpmailer to database only sends one


nanny
04-19-2010, 04:14 AM
Hi I have luck sending to one email using phpmailer class but can't send more than one in the database - does anybody have experience with this. SoI have:

if (array_key_exists('send', $_POST)) {
$subject = $_POST['subject'];
if (empty($subject)) {
$error['subject'] = 'Please put the subject.';
}
$bodypost = $_POST['bodypost'];
if (empty($bodypost)) {
$error['bodypost'] = 'Please put the message.';
}
//$plain = stripslashes($_POST['body']);
if (!isset($error)) {
mysql_select_db($database_add, $add);

require 'mailer/class.phpmailer.php';

try {
$mail = new PHPMailer(true); //New instance, with exceptions enabled

$body = $_POST['bodypost'];
$body = preg_replace('/\\\\/','', $body); //Strip backslashes

$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP server port
$mail->Host = "localhost"; // SMTP server
$mail->Username = ""; // SMTP server username
$mail->Password = ""; // SMTP server password

$mail->IsSendmail(); // tell the class to use Sendmail

$mail->AddReplyTo("info@this.com","this");

$mail->From = "info@this.com";
$mail->FromName = "This";
$query_emailRS = "SELECT * FROM contacts ";
$emailRS = mysql_query($query_emailRS, $add) or die(mysql_error());
$row_emailRS = mysql_fetch_assoc($emailRS);
$totalRows_emailRS = mysql_num_rows($emailRS);
while ($row_emailRS = mysql_fetch_assoc($emailRS));
{
$mail->AddAddress($row_emailRS['email']);

$mail->Subject = $_POST['subject'];

//$mail->AltBody = $plain; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap

$mail->MsgHTML($body);

$mail->IsHTML(true); // send as HTML

$mail->Send();
$mail->ClearAddresses();

header("Location: warranty.php");
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
}
}
}


Well it keeps saying either invalid address or sends only one email.

any suggestions?

edbr
04-19-2010, 04:42 AM
not familliar with it but is it possible it is spam prevention on your server i have known this with mail progs where one only can be sent . check throttle settings usually sleep() time intervals

davidj
04-20-2010, 10:20 AM
Are you looping through your addresses to send multiple mails

I dont see a loop

Am I missing some thing