title: Speed up PHPmailer with office 365 smtp
body: <p>I am using an PHPMailer to send mail from my server through an office365 account.</p>
  
  <p>However it seems to take about 10-12 seconds to send the email, and this is making customers impatient and they are clicking the send button again.</p>
  
  <p>This is my code</p>
  
  <pre><code>$mail-&gt;IsSMTP();                                // enable SMTP
  $mail-&gt;SMTPAuth     = true;                     // turn on SMTP authentication
  $mail-&gt;SMTPSecure   = "tls";                    // Secure type = tls
  $mail-&gt;Host         = "smtp.office365.com";     // Hostname
  $mail-&gt;Username     = "user@domain.co.uk";      // Username
  $mail-&gt;Password     = "password";            // Password
  $mail-&gt;Port         = 587;                      // Office 365 Port
  
  $mail-&gt;IsHTML(true);
  $mail-&gt;setFrom('online@domain.co.uk','Website Email');
  $mail-&gt;AddReplyTo("sales@domain.co.uk","Sales");
  $mail-&gt;AddAddress($value);
  $mail-&gt;Subject($subject);
  $mail-&gt;Body($body);
  if(!$mail-&gt;Send()) {
       $string = date('Y-m-d').','.date('H:i:s').','.$mail-&gt;ErrorInfo;
       $this-&gt;writetolog('mailLog',$string);
   } else {
        echo "Message sent!";
   }
  </code></pre>
  
  <p>The message is sending correctly but it just takes so long to send it.</p>
  
  <p>Is this a common thing or there something I can do to speed the process up at all.</p>
  
  <p>Before i was using the smtp and just sending from the server it was instant but customers were sometimes getting the mail into junk boxes etc and they did not look professional.</p>
  
  <p>Many Thanks.</p>