Attachments using phpmailer

hi all,
I am using the phpmailer to send an attachment(3MB) to to all the members in the database, however in doing so, i receive the following error Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 4680430 bytes) in /home/mysite/public_html/dir1/phpmailer/class.smtp.php on line 308

$mail->FromName = “mysite.org”;
$mail->From = “noreply@mysite.org”;
$mail->AddReplyTo(“noreply@mysite.org”, “mysite”);

$mail->Subject = $subject;
$mail->Body = $message;
$mail->WordWrap = 65;

$sql = “SELECT * FROM invites_test WHERE invitation = 0 LIMIT 0, 3”;
$result = mysql_query($sql) or die(mysql_error());

//attachment
$mail->AddAttachment(“/home/mysite/public_html/dir1/dir/attach.zip”, “attach.zip”);
//attachment

while($row = mysql_fetch_array($result)){
$email=$row[‘email’];
$mail->AddAddress($row[‘email’]);

$mail->Send();
mysql_query(“UPDATE invites_test SET invitation = 1 WHERE email LIKE '”.$email.“%'”);
$mail->ClearAddresses();
}
echo ‘Invitation has been sent.’;
?>

The purpose is to send attachment to all th members

try this:


set_time_limit(0);
ini_set("memory_limit","80M");
ini_set("display_errors", 1);
error_reporting(E_ALL);
$start = (float) array_sum(explode(' ',microtime()));
require("class.phpmailer.php");

$mail = new phpmailer();

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "smtp.xxx.xx"; // SMTP server

$mail->FromName = "mysite.org";
$mail->From = "noreply@mysite.org";
$mail->AddReplyTo("noreply@mysite.org", "mysite");

$mail->Subject = "test subject";
$mail->Body = "test message";
$mail->WordWrap = 65;

mysql_connect("localhost","root","xxx") or die(mysql_error());
mysql_select_db("xxx") or die(mysql_error());

$sql = "SELECT login, email FROM users";
$result = mysql_query($sql) or die(mysql_error());

function fetch_all_array($query_string)
{
	$out = array();
	
	while ($row = mysql_fetch_array($query_string))
	{
		$out[] = $row;
	}
	
	return $out;
}

$all_rows = fetch_all_array($result);

$mail->AddAttachment("d:\\3519K.pdf", "3519K.pdf");

foreach($all_rows as $key => $value)
{
	$mail->AddBCC($value['email'],$value['login']);

	//var_export($mail);
}

$mail->Send();

$mail->ClearAddresses();
$mail->ClearAttachments();
$end = (float) array_sum(explode(' ',microtime()));

echo "Processing time: ". sprintf("%.4f", ($end-$start))." seconds";

//Processing time: 43.3911 seconds for eight recipients, windows xp, php 5, mysql 5