title: PHPmailer using Gmail does not work
body: <p>I'd like to create an email form using gmail but can't get it working.
  I downloaded PHPmailer and uploaded them.
  The form works, it also checks the if the email adsress is correct but does not show a message after hitting the submit button and does not send an email.</p>
  
  <p>I also turned on the access for less secured apps in my gmail settings.</p>
  
  <pre><code>    &lt;?php
  
  // functie spamcheck
  function spamcheck($field)
    {
    //filter_var() sanitizes de email 
    $field=filter_var($field, FILTER_SANITIZE_EMAIL);
  
    //filter_var() valideert de email
    if(filter_var($field, FILTER_VALIDATE_EMAIL))
      {
      return true;
      }
    else
      {
      return false;
      }
    }
  
  if($_SERVER['REQUEST_METHOD'] == 'POST') 
  {  
  
  
  // PHP mailer settings instellen voor GMAIL
  require_once ('contactform/phpmailer/class.phpmailer.php'); // het pad vanaf dit fomulier naar "class.phpmailer.php"
  $mail = new PHPMailer(true);
  $mail-&gt;CharSet = 'utf-8'; //character set utf-8 
  $mail-&gt;IsSMTP();  // smtp protocol gebruiken voor de email te verzenden 
  $mail-&gt;Host = "smtp.gmail.com"; // smtp servernaam van gmail
  $mail-&gt;Port = "587";  // smtp poort voor gmail 465 or 587
  $mail-&gt;SMTPSecure = "tls"; //gmail authenticeert door ssl ( andere optie is tls )
  $mail-&gt;SMTPAuth = true; 
  // account gegevens voor authenticatie Gmailserver
  $mail-&gt;Username = "ethannn@gmail.com"; 
  $mail-&gt;Password = "mypassword";
  $mail-&gt;From = $_POST['email']; 
  $mail-&gt;FromName = $_POST['naam']; 
  $mail-&gt;AddAddress("ethannn@email.com", "Jouw Naam"); // emailadres ontvanger en de naam die in email verschijnt
  $mail-&gt;Subject = "Contactformulier";
  // variabelen voor de body en body email opmaken
  $naam = $_POST['naam'];
  $achternaam = $_POST['achternaam'];
  $email = $_POST['email'];
  $bericht = $_POST['bericht'];
  // body opmaken
  $body = "";
  $body .= "Naam: ";
  $body .= $naam;
  $body .= "&lt;br /&gt;";
  $body .= "Achternaam: ";
  $body .= $achternaam;
  $body .= "&lt;br /&gt;";    
  $body .= "Email: ";
  $body .= $email;
  $body .= "&lt;br /&gt;";
  $body .= "Bericht: ";
  $body .= $bericht;
  $body .= "&lt;br /&gt;";
  
  $mail-&gt;WordWrap = 80; 
  $mail-&gt;MsgHTML($body, dirname(__FILE__), true); // genereren van bodybericht 
  
  // check of submitter een robot is en of er geldige input is geleverd
  $mailcheck = spamcheck($_POST['email']);
  
  if($_POST['robot'] != "test_spambot") {
      die();                  
  } 
  //check of email geldig is
  elseif ($mailcheck == false) {
      echo "Ongeldige input van emailadres";
  }
  else {
  
  // email verzenden 
  $formsent = $mail-&gt;Send(); 
  
  // echo's als verzenden goed of fout is gegaan
  if ($formsent){
    echo 'Uw bericht is successvol verstuurd!'; 
  }
  else{
    echo 'Sorry, maar er is iets misgegaan met het versturen van het formulier; probeer het later nog eens.'; 
      }
    }
  
  } // eind request method
  ?&gt;
  
  &lt;form action="" method="post" name="" id=""&gt;
    &lt;input type="hidden" name="robot" value="test_spambot" /&gt;&lt;br /&gt;
    Naam: &lt;br /&gt;
    &lt;input type="text" name="naam" value ="ethannn"/&gt;&lt;br /&gt;
    Achternaam: &lt;br /&gt;
    &lt;input type="text" name="achternaam" value ="Kikker"/&gt;&lt;br /&gt;
    Email: &lt;br /&gt;
    &lt;input type="text" name="email" value ="kikker@gmail.com"/&gt;&lt;br /&gt;
    Bericht: &lt;br /&gt;
    &lt;textarea name="bericht" /&gt;blablabla&lt;/textarea&gt;
    &lt;br /&gt;&lt;br /&gt;
    &lt;input type="reset" value="Reset" /&gt;
    &lt;input type="submit" value="Verzenden" /&gt;
  &lt;/form&gt;
  </code></pre>