Sending multiple attachments to multiple users - phpmailer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sHuRuLuNi
Forum Newbie
Posts: 16
Joined: Mon Jan 03, 2011 9:06 am

Sending multiple attachments to multiple users - phpmailer

Post by sHuRuLuNi »

Hello,

I've searched the forums but I only find threads about sending ONE attachment, or other problems, but havent found anything about sending multiple attachments to multiple users.

Basically I loop through users database and send them an email. With one attachment it is no problem. But when I tried to use foreach or while to send MULTIPLE attachments (as in there are many PDF documents that will be sent as an attachment in the mail to all the users) it either does not send anything (when using foreach) or it only sends one attachment, usually the last uploaded (when using while).

I've tried many combinations like:

Code: Select all

while($row=mysql_fetch_array($attachmentquery, MYSQL_ASSOC)){
$mailer->AddAttachment("UserFiles/File"."/".$row['att_url']);
}
Is it the problem that e.g. this while statement is used inside another while loop (which sends the email to all the users)?
And if yes, how can it be solved. If foreach is to be used, then how?

Thank you for your help.
sHuRuLuNi
Forum Newbie
Posts: 16
Joined: Mon Jan 03, 2011 9:06 am

Re: Sending multiple attachments to multiple users - phpmail

Post by sHuRuLuNi »

I have now for the time being deactivated the multiple attachments (only 1 will be sent), since I searched everywhere on the net, and in phpmailer forums, and no one seems to have a solution for this.

If any of you guys knows how to do this, please help. I have already tried all other suggestions I found on the net - none of them work, or there are only those where you MANUALLY insert multiple Attachments, but nothing about reading an array of attachments from DB or using while loops ...

Thank you.
Post Reply