在Php Mailer中发送多个具有不同正文的电子邮件

How am i able to send multiple email with different body?

I have this loop for sending email:

UPDATED:

                // $arr[] here contains email from database
                // $arrcount = length of $arr[]

                for ($x = 0; $x < $arrcount; $x++)
                {
                    $email = $arr[$x]; 

                $body = "
                    <div>   
                    <h3>Good Day!</h3>

                            You can now <b> <a href = 'project/welcome/signin.php?email=$email'> sign-in and accept this invitation </a> </b>
                        <br>
                     </div>
                "; 
                    $mail->addAddress($email, "You");
                    $query2 = "Insert into ws_invites(user_id,email,date_invited) values ('$myid','$email',now())";
                    $result2 = mysql_query($query2);
                }
                $mail->addReplyTo('myserver@gmail.com', 'Name');
                $mail->WordWrap = 50;
                $mail->Subject = 'You have been invited';
                $mail->Body    = $body;
                $mail->isHTML(true);
                if(!$mail->send()) { 
                   $fault = "true";
                }

Let's assume I have 3 different emails - email1@gmail.com, email2@gmail.com, email3@gmail.com.

Now what happens here is that the value of the $email of this link: <a href = 'project/welcome/signin.php?email=$email'> is equivalent to email3@gmail.com which is the last recipient of the message and both email1@gmail.com and email2@gmail.com receives that email too which is email3@gmail.com.

So i concluded that the program finishes the loops first before sending email. Now what I want is that each loop sends their corresponding email and not that of the email of the last recipient only. Could this be possible? How?

You can add mail sending in your for loop. This sends in order. But this can be slow. Try this change:

$mail->addReplyTo('myserver@gmail.com', 'Name');
$mail->WordWrap = 50;
$mail->Subject = 'You have been invited';
$mail->isHTML(true);

for ($x = 0; $x < $arrcount; $x++)
{
    $email = $arr[$x];

    $body = "
    <div>
        <h3>Good Day!</h3>
        You can now <b> <a href = 'project/welcome/signin.php?email=$email'> sign-in and accept this invitation </a> </b>
        <br>
    </div>
    ";
    $mail->addAddress($email, "You");
    $query2 = "Insert into ws_invites(user_id,email,date_invited) values ('$myid','$email',now())";
    $result2 = mysql_query($query2);
    $mail->Body = $body;
    if(!$mail->send()) {
       $fault = "true";
    }
}