title: Fatal error: Cannot redeclare PHPMailerAutoload()
body: <p>I am using PHPMailer to send emails from my local host.</p>
  
  <p>I have written a function which is supposed to send emails to registered users who have chosen the option to receive them. (i.e. newsletter subscription, etc)</p>
  
  <pre><code>function email_users($subject, $body) {
      include('core/db/db_connection.php');
      $sql = "SELECT email, first_name FROM `_users` WHERE allow_email = 1";
      $query = mysqli_query($dbCon, $sql);
      while (($row = mysqli_fetch_assoc($query)) !== false) {
          $body = "Hello ". $row['first_name'] . ", &lt;br&gt;&lt;br&gt;" . $body;
          email($row['email'], $subject, $body);
      }
  }
  </code></pre>
  
  <p>The code that is calling the function:</p>
  
  <pre><code>if (isset($_GET['success']) === true &amp;&amp; empty($_GET['success']) === true) {
          ?&gt;
              &lt;h3 class="email_success"&gt;Emails have been sent&lt;/h2&gt;
              &lt;a href="admin.php" class="email_success_a"&gt;Go back to the admin page&lt;/a&gt;
          &lt;?php 
          } else {
              if (empty($_POST) === false) {
                  if (empty($_POST['subject']) === true) {
                      $errors[] = 'A message subject is required.';
                  }
                  if (empty($_POST['body']) === true) {
                      $errors[] = 'A body message is required.';
                  }
                  if (empty($errors) === false) {
                      echo output_errors($errors);
                  } else {
                      email_users($_POST['subject'], $_POST['body']);
                      header('Location: email_users.php?success');
                      exit();
                  }
              }
  // generate email form otherwise
  </code></pre>
  
  <p>Any idea why I'm getting  this error?</p>
  
  <blockquote>
    <p>Fatal error: Cannot redeclare PHPMailerAutoload()  </p>
  </blockquote>
  
  <p>I would also like to point out that even with this error, the function still works and the emails are being sent...</p>
  
  <p>EDIT: As requested, please see below the function using PHPMailer:</p>
  
  <pre><code>function email($user, $subject, $body) {
      require 'phpmailer/PHPMailerAutoload.php';
      $mail = new PHPMailer;
  
   /* $mail -&gt; Host,username,password and other misc stuff
      $mail-&gt;Subject = $subject;
      $mail-&gt;Body    = $body;
      $mail-&gt;AltBody = $body; etc */
  }
  </code></pre>