title: What is causing a Fatal Error when sending email from a contact form via PHP and Swiftmailer?
body: <p>I am new to Swiftmailer and am trying to send mail via a HTML contact form on a localhost (XAMPP).  After pressing the 'submit' button, the error reads:</p>
  
  <blockquote>
    <p>Fatal error: Class 'Swift_SmtpTransport' not found in
    /Applications/XAMPP/xamppfiles/htdocs/testsite/sendmessage.php on line
    23</p>
  </blockquote>
  
  <p>Line 23, 24, and 25 is this section:</p>
  
  <pre><code>$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587, 'tls')
      -&gt;setUsername('foobar@googlemail.com')
      -&gt;setPassword('GENERATED PASSWORD');
  </code></pre>
  
  <p>I am expecting the mail to send at this point, and show me a 'Mail Sent' message, along with the echoed lines within the PHP file, however while I'm seeing a <code>"Mail Sent"</code> confirmation I am also getting the error, and I do not receive an email.</p>
  
  <p>I have consulted the documentation <a href="http://swiftmailer.org/docs/sending.html" rel="nofollow noreferrer">here</a>, and my code contained in <code>'sendmessage.php'</code> appears to be correct:</p>
  
  <pre><code>&lt;?php
  error_reporting(E_ALL);
  
  echo getcwd();
  echo function_exists('proc_open') ? "Yep, that will work" : "Sorry, that won't work";
  
  require_once(dirname(__FILE__)."/swift.php");
  echo 'Mail sent &lt;br /&gt;';
  
  // Grab the post data
  $name = filter_var($_POST['Name'], FILTER_SANITIZE_STRING);
  $usermail = filter_var($_POST['Email'], FILTER_SANITIZE_EMAIL);
  $content = filter_var($_POST['Message'], FILTER_SANITIZE_STRING);
  
  // Construct the body of the email
  $data = "Name: " . $name . "&lt;br /&gt;" . "Email: " . $usermail . "&lt;br /&gt;" . "Message: " . $content;
  
  // Create the transport
  $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587, 'tls')
      -&gt;setUsername('foobar@googlemail.com')
      -&gt;setPassword('GENERATED PASSWORD');
  echo 'line 26 &lt;br /&gt;';
  
  // Create the mailer using the created transport
  $mailer = Swift_Mailer::newInstance($transport);
  $message = Swift_Message::newInstance('This is the subject')
      -&gt;setFrom(array('foobar@googlemail.com' =&gt; 'Feedback Received From User'))
      -&gt;setTo(array('barfoo@gmail.com', 'foobar@googlemail.com' =&gt; 'Lead Recipients'))
      -&gt;setSubject('Here is your Feedback subject')
      -&gt;setBody($data, 'text/html');
  echo 'line 34 &lt;br /&gt;';
  
  // Send the message
  $result = $mailer -&gt; send($message);
  echo $result;
  echo 'line 39&lt;br /&gt;';
  ?&gt;
  </code></pre>
  
  <p><code>proc_open</code> returns a <code>"Yep, that will work"</code>, but as above, I am not receiving the email in my inbox.</p>
  
  <p>I have tried changing the port on the line in question to 25 and 486 with no success.</p>
  
  <p>After a Google search I came across <a href="https://stackoverflow.com/questions/29626658/fatal-error-class-swift-smtptransport-not-found-in">this question</a> which seemingly had the same issue, but the accepted answer did not solve my problem.</p>
  
  <p>Please note that I had a <a href="https://stackoverflow.com/questions/31662334/why-am-i-receiving-a-failed-to-open-stream-error-when-submitting-data-from-a-c">previous question</a> regarding errors with a contact form, and this question follows on from that.</p>