title: How should I upgrade from PHPMailer 5.2 to 6.0?
body: <p>I have a script that currently uses a recent version of PHPMailer 5.2.x. PHPMailer 6.0 has been released, but says it will break backward compatibility – what do I need to do to upgrade?</p>
  
  <pre><code>&lt;?php
  require 'PHPMailerAutoload.php';
  
  $mail = new PHPMailer;
  
  //$mail-&gt;SMTPDebug = 3;                               // Enable verbose debug output
  
  $mail-&gt;isSMTP();                                      // Set mailer to use SMTP
  $mail-&gt;Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
  $mail-&gt;SMTPAuth = true;                               // Enable SMTP authentication
  $mail-&gt;Username = 'user@example.com';                 // SMTP username
  $mail-&gt;Password = 'secret';                           // SMTP password
  $mail-&gt;SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  $mail-&gt;Port = 587;                                    // TCP port to connect to
  
  $mail-&gt;setFrom('from@example.com', 'Mailer');
  $mail-&gt;addAddress('joe@example.net', 'Joe User');     // Add a recipient
  $mail-&gt;addAddress('ellen@example.com');               // Name is optional
  $mail-&gt;addReplyTo('info@example.com', 'Information');
  $mail-&gt;addCC('cc@example.com');
  $mail-&gt;addBCC('bcc@example.com');
  
  $mail-&gt;addAttachment('/var/tmp/file.tar.gz');         // Add attachments
  $mail-&gt;addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  $mail-&gt;isHTML(true);                                  // Set email format to HTML
  
  $mail-&gt;Subject = 'Here is the subject';
  $mail-&gt;Body    = 'This is the HTML message body &lt;b&gt;in bold!&lt;/b&gt;';
  $mail-&gt;AltBody = 'This is the body in plain text for non-HTML mail clients';
  
  if(!$mail-&gt;send()) {
      echo 'Message could not be sent.';
      echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
  } else {
      echo 'Message has been sent';
  }
  </code></pre>