title: PHPMailer not sending all emails to last email address
body: <p>I am using PHPMailer to send emails. I have created a function that sends 3 emails to 3 different email addresses (sending 9 emails in total).</p>
  
  <ul>
  <li>The first email address is receiving all the 3 emails.</li>
  <li>The second email address is receiving 2 emails.</li>
  <li>The third email address is receiving only 1 email.</li>
  </ul>
  
  <p>Why this happening?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>use PHPMailer\PHPMailer\PHPMailer; 
  use PHPMailer\PHPMailer\Exception;
  
  require 'lib/phpmailer/vendor/autoload.php'; 
  
  $mail = new PHPMailer(true);
  
  $mail1 = phpmaileremail($reciever1, $usertype1, $file, $subject1, $body1);
  $mail2 = phpmaileremail($reciever2, $usertype2, $file, $subject2, $body2);
  $mail3 = phpmaileremail($reciever3, $usertype3, $file, $subject3, $body3);
  
  function phpmaileremail($reciever,$usertype, $file, $subject, $body)
  {
      global $mail;
      $mail-&gt;SMTPDebug = 0;                                        
      $mail-&gt;isSMTP();
      $mail-&gt;Host = 'smtp.gmail.com';
      $mail-&gt;SMTPAuth = true;
      $mail-&gt;Username = 'xxx@gmail.com';
      $mail-&gt;Password = 'xxx';
      $mail-&gt;SMTPSecure = 'tls';                               
      $mail-&gt;Port = 587;   
  
      $mail-&gt;setFrom('xxx', 'xxx');            
      $mail-&gt;addAddress($reciever); 
      $mail-&gt;addAddress($reciever, $usertype); 
  
      $mail-&gt;addAttachment($file);
  
      $mail-&gt;isHTML(true);                                   
      $mail-&gt;Subject = $subject; 
      $mail-&gt;Body = $body; 
      $mail-&gt;AltBody = 'NA'; 
      $mail-&gt;send();
  
      echo "Mail sent";
  }
  </code></pre>