Jump to content

Problem sending multiple emails with phpmailer


hashstar

Recommended Posts

Hi there,

 

I am using php mailer and this piece of code: 

 

<?php

require('connect.php');

// Grab our config settings
require_once($_SERVER['DOCUMENT_ROOT'].'/config.php');

// Grab the FreakMailer class
require_once($_SERVER['DOCUMENT_ROOT'].'/include/MailClass.inc');

$result_message = '';

if (isset($_POST['submit'])) {

$errors = array();

if (empty($_POST['email_addresses'])) {
	$errors['emails'] = 'No emails selected.';
}

// here you can/should loop through and verify email addresses to avoid spamming; put a restriction to # of emails allowed to be sent, etc.
// santizing/controlling your email functions is greatly overlooked and can cause your site to be dropped by your hosting provider if your site is being used to send gobs of spam

if (empty($errors)) {

	$result_message = 'There was a problem sending this mail!';

	// instantiate the class
	$mailer = new FreakMailer();

	// Build
	foreach ($_POST['email_addresses'] as $email_address) {
		$mailer->AddBCC($email_address);
	}

	// Set the subject
	$mailer->Subject = 'New Products from The Organic Grow Shop';

	 $mailer->isHTML(true);

	if ($mailer->Send()) {
		$result_message = 'Mail sent!';
	}
       
	$mailer->ClearAddresses();
	$mailer->ClearAttachments();
}
}

$sql = "SELECT * FROM mailinglist";
if ($result = mysql_query($sql)) {
if (mysql_num_rows($result) > 0) {
	echo (!empty($result_message) ? $result_message .'<br/><br/>' : '');
	echo "
		<h1>Mailing List</h1>
		Send to<br/><br/>
		<form action='send.php' method='POST'>
	";

	while ($getrow = mysql_fetch_assoc($result)) {
		echo "<input type='checkbox' name='email_addresses[]' value='". $getrow['email'] ."' unchecked='unchecked'/>". $getrow['email'] ."<br>";
	}

	echo "<input type='submit' name='submit' value='Send »'/></form>";
}
else {
	echo 'Add some email addresses.';
}
}
else {
trigger_error(mysql_error());
}
?>

 

 

I can send emails to multiple address ok, have tested sending to 5 addresses at once and this worked fine, but when i try and send the email to everyone in my database it doesn't work. I think what might be happening is that there are emails in my database that aren't correct and this is stopping it from sending out the rest of the emails when it gets to that point. Does that sound plausible?  What else could it be?

 

is there a way to weed out any incorrect emails from my database?

 

 

Any help is much appreciated!!!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.