title: phpmailer get recipients from text file
body: <p>before I post this thread, I search my question, but I see only how to get recipients from database or other is with only mail() function.</p>
  
  <p>I want to send emails from txt file, but my code send only first email from text document.</p>
  
  <pre><code>  &lt;?php
    include("msd/mail.php");
    $file = fopen("emails.txt",  "r");
         $line = fgets($file);
          $to = $line;
    $subject = "Approve your signup";
    $body = "Hello, to approve your registration please click this link";
    $mail = new Mail();
    $mail-&gt;CharSet = 'UTF-8';
    $mail-&gt;FromName = "myweb.com";
    $mail-&gt;addAddress($to);
    $mail-&gt;subject($subject);
    $mail-&gt;body($body);
    if(!$mail-&gt;send())
   {
              echo "Error Sending Email!"; 
           }
           else
          { 
              echo "Mail sent!"; 
          }
  
      ?&gt;
  </code></pre>
  
  <p>emails.txt</p>
  
  <pre><code>test@gmail.com
  test2@gmail.com
  test3@gmail.com
  </code></pre>