Jump to content

PhpMailerLite sending multiple copies


rosbif

Recommended Posts

:brickwall I'm pulling my hair out over this one...

 

I have an php page that produces invoices.  I've got it working that it picks out the records that need an invoice, produces the invoice and stores that invoice on line.  It loops fine to go through all the records.

 

I also want to send a copy of the invoice out to each record holder (family).  So I added phpmailer lite and am using that.  Trouble is, it is sending the first family's invoice to the first family, then the second family receives their invoice plus another email with the first family's invoice, then the third family receives three emails and so on....

 

I have the ClearAddresses(), ClearAllRecipients() and ClearAttachments() lines in but it doesn't seem to be make a difference!

 

My code is this, and it is put just after the invoices are written to storage (which works fine so the loop is fine).

 

$phpmail->ClearAddresses();
$phpmail->ClearAllRecipients();
$phpmail->ClearAttachments();
$phpmail->SetFrom('me@me.com');
$phpmail->AddAddress($to, $parents);
$phpmail->Subject = $title;
$phpmail->MsgHTML($htmlcontent);
$phpmail->AddAttachment($filesname,'invoice.htm','7bit','text/html');

if(!$phpmail->Send()) {
	echo "Mailer Error (" . str_replace("@", "@", $familyemail) . ') ' . $phpmail->ErrorInfo . '<BR>';
			** else {
				echo "Message sent to :" . $parents . ' (' . str_replace("@", "@", $to) . ')<BR>';
				**

 

Any ideas?  I've tried with the ClearAddresses stuff before and after the sending, and have even tried adding $phpmail->SingleTo = true; but it doesn't help.

 

If I comment out the $phpmail->send() line everything is fine - one line in a table is produced for each record, one invoice is saved to file. As soon as I include the send() instruction it is sending out nearly 2000 emails instead of 124; 1 to the first record, 2 to the second, 3 to the third etc...

 

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.