title: Send two different email with attachement with phpmailer
body: <p>I've a problem and I can't figure out where is.
  I've form that will send two different mail:</p>
  
  <ol>
  <li>a simple thank-you-mail that need to be delivered ONLY to who has compiled the form, with an attachement</li>
  <li>a second mail that need to be delivered ONLY to the owner of the website, that will reply, with the same attachement</li>
  </ol>
  
  <p>My problem is that, with phpmailer, the client that compiled the form is receiving both mail. And of course he doesn't have to see the second mail.</p>
  
  <p>here's my code:</p>
  
  <pre><code>$to = $email; 
  $subject = "Princype - la tua configurazione"; 
  $message =
  "Buongiorno $nome, &lt;br&gt;
  in allegato potrai trovare le tua configurazione per il tuo $taglio $style.
  &lt;br&gt;
  A breve entrerai in contatto con un nostro incaricato breve per confermare o fissare un appuntamento.
  &lt;br&gt;
  Cordialmente,
  &lt;br&gt;&lt;br&gt;";
  
  
  
  
  // email stuff 2
  $to2 = "info@info.com"; 
  $subject2 = "Princype - richiesta info per $taglio $style - $id_planimetria"; 
  $message2 =
  "Una nuova richiesta per l'appartamento $taglio $style - $id_planimetria,
  &lt;br&gt;
  &lt;br&gt;
  Nome: $nome &lt;br&gt;
  Cognome: $cognome &lt;br&gt;
  email: $email &lt;br&gt;
  Telefono: $telefono &lt;br&gt;";
  
  
  
  //first email
  try {
  
      $mail-&gt;isSMTP();                                                    // Set mailer to use SMTP
      $mail-&gt;Host       = 'smtps.XXX.com';                               // Specify main and backup SMTP servers
      $mail-&gt;SMTPAuth   = true;                                           // Enable SMTP authentication
      $mail-&gt;Username   = 'info@info.com';                 // SMTP username
      $mail-&gt;Password   = 'XXXXXXX';                             // SMTP password
      $mail-&gt;SMTPSecure = 'ssl';                                          // Enable TLS encryption, `ssl` also accepted
      $mail-&gt;Port       = 000;                                            // TCP port to connect to
  
      //Recipients
      $mail-&gt;setFrom('info@info.com', 'info service');
      $mail-&gt;addAddress($to, sprintf('%s %s', $nome, $cognome));           // Add a recipient
  
      $mail-&gt;addReplyTo('info@info.com', 'info service');
  
  
      // Attachments
                    // Add attachments
      $mail-&gt;addAttachment($filepath, $filename);                            // Optional name
  
      // Content
      $mail-&gt;isHTML(true);                                                   // Set email format to HTML
      $mail-&gt;Subject = $subject;
      $mail-&gt;Body    = $message;
      $mail-&gt;AltBody = $message;
  
      $mail-&gt;send();
  
      //second mail
      $mail-&gt;setFrom('info@info.com', 'info service');
      $mail-&gt;addAddress('info@info.com', 'info service');           // Add a recipient
      $mail-&gt;addReplyTo($to, sprintf('%s %s', $nome, $cognome));
  
  
      $mail-&gt;Subject = $subject2;
      $mail-&gt;Body    = $message2;
      $mail-&gt;AltBody = $message2;
  
      $mail-&gt;send();
      // echo 'Message has been sent';
  } catch (Exception $e) {
      error_log( "Message could not be sent. Mailer Error: {$mail-&gt;ErrorInfo}");
  }}?&gt;
  </code></pre>