title: how to send smtp mail from localhost
body: <p>I always get this message when trying to send email from my local host. </p>
  
  <p>SMTP Error: Could not connect to SMTP host. Message could not be sent.
  Mailer Error: SMTP Error: Could not connect to SMTP host.</p>
  
  <p>below is my code:  please help</p>
  
  <p><div class="snippet" data-lang="js" data-hide="true">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  // $email and $message are the data that is being
  // posted to this page from our html contact form
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;
  
  // When we unzipped PHPMailer, it unzipped to
  // public_html/PHPMailer_5.2.0
  require("class.phpmailer.php");
  
  $mail = new PHPMailer();
  
  // set mailer to use SMTP
  $mail-&gt;IsSMTP();
  
  // As this email.php script lives on the same server as our email server
  // we are setting the HOST to localhost
  $mail-&gt;Host = "localhost";  // specify main and backup server
  
  $mail-&gt;SMTPAuth = true;     // turn on SMTP authentication
  
  // When sending email using PHPMailer, you need to send from a valid email address
  // In this case, we setup a test email account with the following credentials:
  // email: send_from_PHPMailer@bradm.inmotiontesting.com
  // pass: password
  $mail-&gt;Username = "project@reliable.com.pk";  // SMTP username
  $mail-&gt;Password = "Nov112014"; // SMTP password
  
  // $email is the user's email address the specified
  // on our contact us page. We set this variable at
  // the top of this page with:
  // $email = $_REQUEST['email'] ;
  $mail-&gt;From = $email;
  
  // below we want to set the email address we will be sending our email to.
  $mail-&gt;AddAddress("mani9418@gmail.com", "Usman Ali Siddiqui");
  
  // set word wrap to 50 characters
  $mail-&gt;WordWrap = 50;
  // set email format to HTML
  $mail-&gt;IsHTML(true);
  
  $mail-&gt;Subject = "You have received feedback from your website Etutionhub!";
  
  // $message is the user's message they typed in
  // on our contact us page. We set this variable at
  // the top of this page with:
  // $message = $_REQUEST['message'] ;
  $mail-&gt;Body    = $message;
  $mail-&gt;AltBody = $message;
  
  if(!$mail-&gt;Send())
  {
     echo "Message could not be sent. &lt;p&gt;";
     echo "Mailer Error: " . $mail-&gt;ErrorInfo;
     exit;
  }
  
  echo "Message has been sent";
  ?&gt;</code></pre>
  </div>
  </div>
  </p>