title: How can I send form data over SMTP using HTML and PHP?
body: <p>I've developed a website for a client (that will be hosted on their private server) that includes an enrollment form. Users input their first name, last name, email, phone number, and zip code. They also use a radio button to select if they've used the product before, and can check a box to receive news about the product.</p>
  <p>That info is supposed to be sent using SMTP to an email address they handle. They then process the registry internally. So all it needs to do is collect the information and send it in an email. For the SMTP configuration the client has provided me with an IP address, a Port number, and they have stated that there is no Username or Password and no Encryption.</p>
  <p>I have tried to follow many different tutorials online but I am new to PHP and have not been able to make it work.</p>
  <p>Here is the html for the form:</p>
  <pre><code>&lt;form id=&quot;enrollmentForm&quot; name=&quot;email-form-3&quot; action=&quot;&quot; method=&quot;post&quot; class=&quot;eForm&quot;&gt;
      &lt;label for=&quot;nombre&quot; class=&quot;labels&quot;&gt;FIRST NAME&lt;/label&gt;
      &lt;input type=&quot;text&quot; class=&quot;w-input&quot; maxlength=&quot;256&quot; name=&quot;fName&quot; id=&quot;fName&quot; required=&quot;&quot;&gt;
  
      &lt;label for=&quot;apellido&quot; class=&quot;labels&quot;&gt;LAST NAME&lt;/label&gt;
      &lt;input type=&quot;text&quot; class=&quot;text-field w-input&quot; maxlength=&quot;256&quot; name=&quot;lName&quot; id=&quot;lName&quot; required=&quot;&quot;&gt;
  
      &lt;label for=&quot;email&quot; class=&quot;labels&quot;&gt;EMAIL&lt;/label&gt;
      &lt;input type=&quot;text&quot; class=&quot;w-input&quot; maxlength=&quot;256&quot; name=&quot;email&quot; id=&quot;email&quot; required=&quot;&quot;&gt;
  
      &lt;label for=&quot;phone&quot; class=&quot;labels&quot;&gt;PHONE&lt;/label&gt;
      &lt;input type=&quot;text&quot; class=&quot;text-field-2 w-input&quot; maxlength=&quot;256&quot; name=&quot;phone&quot; id=&quot;phone&quot; required=&quot;&quot;&gt;
  
      &lt;label for=&quot;zip&quot; class=&quot;labels&quot;&gt;ZIP CODE&lt;/label&gt;
      &lt;input type=&quot;text&quot; class=&quot;w-input&quot; maxlength=&quot;256&quot; name=&quot;zip&quot; id=&quot;zip&quot; required=&quot;&quot;&gt;
  
      &lt;label class=&quot;labels check&quot;&gt;HAVE YOU USED OUR PRODUCT BEFORE?&lt;/label&gt;
      &lt;label id=&quot;usedBeforeYes&quot; class=&quot;w-radio&quot;&gt;
      &lt;input type=&quot;radio&quot; name=&quot;usedBefore&quot; id=&quot;si&quot; value=&quot;si&quot; data-name=&quot;usedBefore?&quot; required=&quot;&quot; class=&quot;w-form-formradioinput w-radio-input&quot;&gt;&lt;span class=&quot;labels w-form-label&quot; for=&quot;si&quot;&gt;YES&lt;/span&gt;&lt;/label&gt;
  
      &lt;label id=&quot;usedBeforeNo&quot; class=&quot;w-radio&quot;&gt;
      &lt;input type=&quot;radio&quot; name=&quot;usedBefore&quot; id=&quot;no&quot; value=&quot;no&quot; data-name=&quot;usedBefore?&quot; required=&quot;&quot; class=&quot;w-form-formradioinput w-radio-input&quot;&gt;&lt;span class=&quot;labels w-form-label&quot; for=&quot;no&quot;&gt;NO&lt;/span&gt;&lt;/label&gt;
  
      &lt;label class=&quot;w-checkbox&quot;&gt;
          &lt;input type=&quot;checkbox&quot; id=&quot;checkBox&quot; name=&quot;checkBox&quot; class=&quot;w-checkbox-input&quot;&gt;
          &lt;span class=&quot;checkbox-label-2 w-form-label&quot; for=&quot;checkbox-6&quot;&gt;Would you like to receive more information about our product?&lt;/span&gt;
      &lt;/label&gt;
  
      &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;SUBMIT&quot; data-wait=&quot;One moment...&quot; class=&quot;button w-button&quot;&gt;
  
  &lt;/form&gt;
  </code></pre>
  <p>This is the PHP I have been trying to use:</p>
  <pre><code>&lt;?php
  
  if (isset($_POST[&quot;submit&quot;]))
  {
      $message =  &quot;Info:&quot; . &quot;\n\n\n&quot;
      . &quot;First Name: &quot; . $_POST[&quot;fName&quot;] . &quot;\n&quot;
      . &quot;Last Name: &quot; . $_POST[&quot;lName&quot;] . &quot;]n&quot;
      . &quot;Email: &quot; . $_POST[&quot;email&quot;] . &quot;\n&quot;
      . &quot;Phone Number: &quot; . $_POST[&quot;phone&quot;] . &quot;\n&quot;
      . &quot;Zip Code: &quot; . $_POST[&quot;zip&quot;] . &quot;\n&quot;
      . &quot;Repeat Customer?: &quot; . $_POST[&quot;usedBefore&quot;] . &quot;\n&quot;
      . &quot;Send news?: &quot; . $_POST[&quot;checkBox&quot;];
      $mailTo = &quot;internalEmail@client.com&quot;;
      $subject = &quot;Customer Registry&quot;;
          
      require 'class\PHPMailer.php';
      $mail = new PHPMailer(true);
      $mail-&gt;IsSMTP();
      $mail-&gt;setFrom($mailTo, 'Registry');
      $mail-&gt;Username = '';
      $mail-&gt;Password = '';
      $mail-&gt;Host = 'ip address provided';
      $mail-&gt;Port = 'port provided';
      $mail-&gt;SMTPSecure = 'tls';
      $mail-&gt;From = $mailTo;
      $mail-&gt;AddAddress($mailTo, 'Registry');
      $mail-&gt;isHTML(true);
      $mail-&gt;Subject = $subject;
      $mail-&gt;Body = $message;
      $mail-&gt;Send();
      if ($mail-&gt;Send())
      {
          echo('Message sent successfully');
      }
      else
      {
          echo('Error while sending message');
      }
  }
  ?&gt;
  </code></pre>
  <p>Many thanks in advance!</p>