rosbif Posted July 20, 2010 Share Posted July 20, 2010 :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... Quote Link to comment https://forums.phpfreaks.com/topic/208347-phpmailerlite-sending-multiple-copies/ Share on other sites More sharing options...
rosbif Posted July 21, 2010 Author Share Posted July 21, 2010 When sending the page seems to refresh itself constantly for some reason. I have seen another post that suggests putting a pause in after the send - would that make a difference? Quote Link to comment https://forums.phpfreaks.com/topic/208347-phpmailerlite-sending-multiple-copies/#findComment-1089246 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.