title: Send email Asynchronously via PhpMailer
body: <p>I am using PHPMailer to send email which works great. The issue however is that since it sends the email synchronously, the subsequent page load takes a long time. </p>
  
  <p>I am using PhpMailer as shown in this example <a href="https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps" rel="nofollow">https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps</a></p>
  
  <p>I wonder if there is a way to make email delivery asynchronous. I researched this and found that sendmail has an option to set DeliveryMode to "background mode" - source <a href="http://php.net/manual/en/function.mail.php" rel="nofollow">http://php.net/manual/en/function.mail.php</a></p>
  
  <pre><code>mail($to, $subject, $message, $headers, 'O DeliveryMode=b');
  </code></pre>
  
  <p>I want to know if something similar can be done in PhpMailer? Has anyone had any success with this?</p>
  
  <p><strong>EDIT:- (Additional info)</strong> It seems like PhpMailer can be configured to  use sendmail - <a href="https://github.com/PHPMailer/PHPMailer/blob/master/class.phpmailer.php" rel="nofollow">https://github.com/PHPMailer/PHPMailer/blob/master/class.phpmailer.php</a>
  Therefore I wonder if this can be somehow leveraged to enable background delivery.</p>
  
  <pre><code>/**
   * Which method to use to send mail.
   * Options: "mail", "sendmail", or "smtp".
   * @type string
   */
  public $Mailer = 'mail';
  
  /**
   * The path to the sendmail program.
   * @type string
   */
  public $Sendmail = '/usr/sbin/sendmail';
  /**
   * Whether mail() uses a fully sendmail-compatible MTA.
   * One which supports sendmail's "-oi -f" options.
   * @type boolean
   */
  public $UseSendmailOptions = true;
  
  /**
   * Send messages using $Sendmail.
   * @return void
   */
  public function isSendmail()
  {
      $ini_sendmail_path = ini_get('sendmail_path');
      if (!stristr($ini_sendmail_path, 'sendmail')) {
          $this-&gt;Sendmail = '/usr/sbin/sendmail';
      } else {
          $this-&gt;Sendmail = $ini_sendmail_path;
      }
      $this-&gt;Mailer = 'sendmail';
  }
  </code></pre>
  
  <p>Also - apparently there is way to set sendmail options via php.ini
  <a href="http://blog.oneiroi.co.uk/linux/php/php-mail-making-it-not-suck-using-sendmail/" rel="nofollow">http://blog.oneiroi.co.uk/linux/php/php-mail-making-it-not-suck-using-sendmail/</a></p>
  
  <p>I would prefer to do this as an inline argument to the api call vs php.ini so that isnt a global change. Has anyone tried this?</p>