If I send one email per recipient via phpmailer, everything's beautiful.

If I make a list of recipients, nothing happens no matter how the list's delimited. I've tried commas, semicolons, tabs, spaces.

If I break the list of recipients into an array and submit the array, nothing.

If I'm sending the same email to three people, do I need to close phpmailer and re-initialize it between sends? If so, how do I close it?

Thanks,
- Paul

    Perhaps you should read the documentation on phpmailer? There's an example here that uses the phpmailer method 'AddAddress'. I would imagine you could create a single message and call that however many times you need to add the recipients.

    RTFM!

      When I returned to this list to read your reply I was surprised to notice I hadn't included the reason I wrote:

      $mail = new PHPMailer();
      $body = $mail->getFile('contents.html');
      $mail->From = $fm;
      $mail->FromName = $fulnam;
      $mail->Subject = $subj;
      $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional
      $mail->MsgHTML($body);

      $emailz = explode(";",$recipients);
      $mailCt = count($emailz);

      for($i=0; $i<$mailCt; $i++){
      $tu= $emailz[$i];
      $mail->AddAddress($tu);
      }

      With the loop here, a "To:" list is accumulated while the mailing is in progress. The email is first sent to the first name; then, to the first and second names; then, the first, second and third names, and so on, ending (I trust but do not believe) in the grave.

      The manual seems to recommend moving the loop earlier in the function. I did that. The result was not pretty.

      The application I'm finishing isn't designed to extract mailing info from the database at this point. If I need to, I'll change the code to do it, but I don't see why looping through a db table would be any different from looping through an array of email addresses.

      Coould anyone lead me out of this? I would be ever so grateful...

      Now, I'm going to go drive around for a half hour and scream at the top of my lungs. It's a very refreshing thing to do, you know.

        I don't see any call to set $mail->Host or $mail->Mailer or $mail->From or, most importantly $mail->Send();

        Also, you may want to try and check your mail log (or have your sysadmin help you do so) to see if anything is actually getting mailed.

        Lastly, just because it gets mailed doesn't mean it will ever arrive. You may also find this thread useful:

        http://www.phpbuilder.com/board/showthread.php?s=&postid=10781635

          You have to call ->clearAddresses(); if you want to keep sending to different people. You're constantly adding to the recipient stack in the for loop.

            Write a Reply...