title: How to set phpmailer autoresponder?
body: <p>Please guide me how to set auto respond email based on my code:
  This following code is working well, and all emails will go to inbox folder no issue. </p>
  
  <pre><code>    &lt;?php
  sleep(3);
  $recipients = 'recipients-email';
  try {
  require './phpmailer/PHPMailerAutoload.php';
  preg_match_all("/([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)/", $recipients, $addresses, PREG_OFFSET_CAPTURE);
  if (!count($addresses[0])) {
      die('MF001');
  }
  if (preg_match('/^(127\.|192\.168\.)/', $_SERVER['REMOTE_ADDR'])) {
      die('MF002');
  }
  $template = file_get_contents('rd-mailform.tpl');
  if (isset($_POST['form-type'])) {
      switch ($_POST['form-type']){
          case 'contact':
              $subject = 'A message from your site visitor';
              break;
          case 'subscribe':
              $subject = 'Subscribe request';
              break;
          case 'order':
              $subject = 'Order request';
              break;
          default:
              $subject = 'A message from your site visitor';
              break;
      }
  }else{
      die('MF004');
  }
  if (isset($_POST['email'])) {
      $template = str_replace(
          array("&lt;!-- #{FromState} --&gt;", "&lt;!-- #{FromEmail} --&gt;"),
          array("Email:", $_POST['email']),
          $template);
  }else{
      die('MF003');
  }
  if (isset($_POST['message'])) {
      $template = str_replace(
          array("&lt;!-- #{MessageState} --&gt;", "&lt;!-- #{MessageDescription} --&gt;"),
          array("Message:", $_POST['message']),
          $template);
  }
  preg_match("/(&lt;!-- #{BeginInfo} --&gt;)(.|\n)+(&lt;!-- #{EndInfo} --&gt;)/", $template, $tmp, PREG_OFFSET_CAPTURE);
  foreach ($_POST as $key =&gt; $value) {
      if ($key != "email" &amp;&amp; $key != "message" &amp;&amp; $key != "form-type" &amp;&amp; !empty($value)){
          $info = str_replace(
              array("&lt;!-- #{BeginInfo} --&gt;", "&lt;!-- #{InfoState} --&gt;", "&lt;!-- #{InfoDescription} --&gt;"),
              array("", ucfirst($key) . ':', $value),
              $tmp[0][0]);
          $template = str_replace("&lt;!-- #{EndInfo} --&gt;", $info, $template);
      }
  }
  $template = str_replace(
      array("&lt;!-- #{Subject} --&gt;", "&lt;!-- #{SiteName} --&gt;"),
      array($subject, $_SERVER['SERVER_NAME']),
      $template);
  $mail = new PHPMailer();
  $mail-&gt;isSMTP();                                      // Set mailer to use SMTP
  $mail-&gt;Host = '';       // Specify main and backup SMTP servers
  $mail-&gt;SMTPAuth = true;                               // Enable SMTP authentication
  $mail-&gt;Username = '';                 // SMTP username
  $mail-&gt;Password = '';                           // SMTP password
  $mail-&gt;SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  $mail-&gt;Port = 587; 
  $mail-&gt;setFrom('', '');
  $mail-&gt;addAddress('', 'Information Center');     // Add a recipient
  $mail-&gt;addReplyTo('', 'Information');
  foreach ($addresses[0] as $key =&gt; $value) {
      $mail-&gt;addAddress($value[0]);
  }
  $mail-&gt;CharSet = 'utf-8';
  $mail-&gt;Subject = $subject;
  $mail-&gt;MsgHTML($template);
  if (isset($_FILES['attachment'])) {
      foreach ($_FILES['attachment']['error'] as $key =&gt; $error) {
          if ($error == UPLOAD_ERR_OK) {
              $mail-&gt;AddAttachment($_FILES['attachment']['tmp_name'][$key], $_FILES['Attachment']['name'][$key]);
          }
      }
  }
     $mail-&gt;send();
  die('MF000');
  } catch (phpmailerException $e) {
  die('MF254');
  } catch (Exception $e) {
  die('MF255');
  }
  ?&gt;
  </code></pre>
  
  <p>I tried to add this following code, but all emails will go to spam folder. How to solve the issue?</p>
  
  <pre><code>    if ($mail-&gt;send()){ 
  require_once('./phpmailer/class.phpmailer.php');
  $mail             = new PHPMailer(); 
  $mail-&gt;Host = '';  // Specify main and backup SMTP servers
  $mail-&gt;SMTPAuth = true;                               // Enable SMTP authentication
  $mail-&gt;Username = '';                 // SMTP username
  $mail-&gt;Password = '';                           // SMTP password
  $mail-&gt;SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  $mail-&gt;Port = 587; 
  $mail-&gt;setFrom('no-reply@email.com');
  $to = $_POST['email'];
  $subject = 'Thanks for contacting us';
  $msg = 'Hello, thanks for contacting us';
  mail($to, $subject, $msg);
  } 
  </code></pre>
  
  <p><strong>This is my question:</strong></p>
  
  <p><strong>1) my above code is working, but mails will go to spam folder <em>(Just in section of auto response)</em>. How to solve the case?</strong></p>
  
  <p>Regards</p>