title: Email spoofing error: form is sending from submitted email, not server/domain
body: <p>For example, if we enter any email in the form, we receive an email spoofing error when submitting the form. However, the form sends without error if we enter an email from the domain of the website.</p>
  <p>How do we change the email to be sent from the domain instead of the email submitted from the form?</p>
  <p>Thank you in advance for your time and skill. </p>
  <pre><code>         * Server settings 
           */
          // $mail-&gt;SMTPDebug = SMTP::DEBUG_SERVER;                // Enable verbose debug output
          // $mail-&gt;SMTPDebug = 2;
          $mail-&gt;isSMTP();                                         // Send using SMTP
          $mail-&gt;Host       = 'smtp.ipage.com';                    // Set the SMTP server to send through
          $mail-&gt;SMTPAuth   = true;                                // Enable SMTP authentication
          $mail-&gt;Username   = 'contact@mikesledztattoo.com';       // SMTP username
          $mail-&gt;Password   = 'password';                  // SMTP password
          $mail-&gt;SMTPSecure = &quot;tls&quot;;                              // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
          $mail-&gt;Port       = 587;                                 // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above  
          // $mail-&gt;SMTPSecure = &quot;tls&quot;;                            // Enable TLS encryption, `ssl` also accepted
          // $mail-&gt;Port = 587;                                    // TCP port to connect to
  
          // Name
          if (array_key_exists('name', $_POST)) {
            //Limit length and strip HTML tags
            $name = substr(strip_tags($_POST['name']), 0, 255);
          } else {
              $name = '';
              $msg .= &quot;Error: invalid name provided (1)&quot;;
              $err = true;
          }
  
          // Phone
          if (array_key_exists('phone', $_POST)) {
              //Limit length and strip HTML tags
              $phone = substr(strip_tags($_POST['phone']), 0, 15);
          } else {
              $phone = 'Not A  Valid Phone';
              $msg .= &quot;Error: invalid phone number provided (2)&quot;;
              $err = true;
          }
      
          // Email
          // Make sure the address they provided is valid before trying to use it
  
          if (array_key_exists('email', $_POST) and (PHPMailer::validateAddress($_POST['email'], 'php'))){
              // $email = $_POST['email'];
              $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); 
          } else {
              $msg .= &quot;Error: invalid email provided&quot;;
              $err = true;
          }
  
          // Message
          // Apply some basic validation and filtering to the query / message
          if (array_key_exists('message', $_POST)) {
              //Limit length and strip HTML tags
              $message = nl2br($_POST['message']);
              // $message = nl2br($_POST['message']);
              // $message = utf8_encode(filter_var($_POST['message'], FILTER_SANITIZE_STRING));
              // $message = htmlspecialchars($_POST['message']);
              // $message = strip_tags(htmlentities($_POST['message'], ENT_QUOTES),'&lt;br&gt;&lt;p&gt;');
          } else {
              $message = '';
              $msg = 'No message provided!';
              $err = true;
          }
  
          //Recipients
          $mail-&gt;setFrom($_POST['email'], $_POST['name']);
          $mail-&gt;addAddress('personalemail@gmail.com', 'Mike S');
          $mail-&gt;addReplyTo('$email', '$name');
  
          $mail-&gt;Subject = 'MikeSledzTattoo.com Tattoo Inqury - '.$name;
          $mail-&gt;Body = $name . '&lt;br&gt;' . $email . '&lt;br&gt;' . $phone . '&lt;br&gt;'  . $message . '&lt;br&gt;';
          $mail-&gt;AltBody = $name . '\n' . $email . '\n' . $phone . '\n'  . $message . '\n';
  
          $mail-&gt;isHTML(true); // Set email format to HTML
  
          $error_count = 0;
          $image_count = 0;
          for ($ct = 0, $ctMax = count($_FILES['userfile']['tmp_name']); $ct &lt; $ctMax; $ct++) {
              $image_count++;
              // Extract an extension from the provided filename
              $ext = PHPMailer::mb_pathinfo($_FILES['userfile']['name'], PATHINFO_EXTENSION);
  
              // Define a safe location to move the uploaded file to, preserving the extension
              $uploadfile = tempnam(sys_get_temp_dir(), $_FILES['userfile']['name'][$ct]) . '.' . $ext;
              $filename = $_FILES['userfile']['name'][$ct];
              
              if (move_uploaded_file($_FILES['userfile']['tmp_name'][$ct], $uploadfile)) {
                  if (!$mail-&gt;addAttachment($uploadfile, $filename)) {
                      $msg .= 'Failed to attach file '.$image_count.' ' . $filename;
                  }
              } else {
                  $error_count++;
                  $adds_var = ($error_count &gt; 1 ? 's' : ''); 
                  $msg .= &quot;&lt;p&gt;Failed to move image &quot;.$image_count.&quot; into the email. This image was too large or corrupted.&lt;/p&gt;&quot;;
              }
          }
    
          /* HTML Email Template*/
          ob_start();
          include('vendor/htmlemail/index.php');
          $mail-&gt;Body = ob_get_contents();
          ob_end_clean();
  
          // Mail Send Errors or Confirmation
          if (!$mail-&gt;send()) {
              $msg .= 'Mailer Error: ' . $mail-&gt;ErrorInfo;
          } else {
              $msg .= '
              &lt;br&gt;&lt;br&gt;&lt;h1 class=&quot;entry-title page-title center-text&quot;&gt;Tattoo Request Sent!&lt;/h1&gt;';
  
              $msg .= '
              &lt;div class=&quot;last&quot;&gt;
                  &lt;p&gt;Thank you for sharing your dream tattoo details. We appreciate your interest in working with us. Mike Sledz Tattoo will get back to you shortly!&lt;/p&gt;
              &lt;/div&gt;';
          }
  }
  ?&gt;
  &lt;!DOCTYPE HTML&gt;
  &lt;html lang=&quot;en-US&quot;&gt;
      &lt;head&gt;
          &lt;title&gt;Mike Sledz Tattoo | Contact&lt;/title&gt;
          &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;
          &lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;
          &lt;meta name=&quot;keywords&quot; content=&quot;&quot; /&gt;
          &lt;meta name=&quot;author&quot; content=&quot;&quot; /&gt;
          &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, maximum-scale=1&quot;&gt;
          &lt;meta name=&quot;robots&quot; content=&quot;follow,noindex&quot;&gt;
  
          &lt;?php include('head.php'); ?&gt;
          
          &lt;!--[if lt IE 9]&gt;
                  &lt;script src=&quot;js/html5shiv.js&quot;&gt;&lt;/script&gt;            
                  &lt;script src=&quot;js/respond.min.js&quot;&gt;&lt;/script&gt;                   
          &lt;![endif]--&gt;
  
      &lt;/head&gt;
  
      &lt;body class=&quot;page-background&quot;&gt;
  
          &lt;div class=&quot;site-wrapper&quot;&gt;                  
  
              &lt;?php include('nav.php'); ?&gt;
  
              &lt;!-- Page Content Holder --&gt;
              &lt;div id=&quot;content&quot; class=&quot;site-content&quot;&gt;
                  &lt;div class=&quot;content-holder center-relative content-1170&quot;&gt;
                  &lt;?php if ($books == 1) {
                          if (empty($msg)) { ?&gt;
                              &lt;h1 class=&quot;entry-title page-title center-text&quot;&gt;Request A Tattoo&lt;/h1&gt;
                              &lt;p&gt;Please include all necessary information, &lt;em&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://squoosh.app/&quot;&gt;consider preparing any large images for email&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
                              &lt;div class=&quot;last&quot;&gt;
                                  &lt;div class=&quot;contact-form&quot;&gt;
                                  &lt;!-- BEGIN FORM STATE --&gt;
                                  &lt;form method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
                                      &lt;label for=&quot;name&quot;&gt;Full Name:&lt;/label&gt;
                                      &lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; maxlength=&quot;255&quot; placeholder=&quot;Full Name&quot; required&gt;&lt;br&gt;
                                      &lt;br&gt;
                                      &lt;label for=&quot;phone&quot;&gt;Phone:&lt;/label&gt;
                                      &lt;input type=&quot;tel&quot; name=&quot;phone&quot; id=&quot;name&quot; maxlength=&quot;15&quot; placeholder=&quot;Phone Number&quot; required&gt;&lt;br&gt;
                                      &lt;br&gt;
                                      &lt;label for=&quot;email&quot;&gt;Email:&lt;/label&gt;
                                      &lt;input type=&quot;email&quot; name=&quot;email&quot; id=&quot;email&quot; maxlength=&quot;255&quot; placeholder=&quot;Email&quot; required&gt;&lt;br&gt;
                                      &lt;br&gt;
                                      &lt;label for=&quot;message&quot;&gt;Tattoo Details &lt;em style=&quot;font-size:0.8em;opacity:0.7;&quot;&gt;description, where, size, placement&lt;/em&gt;&lt;/label&gt;
                                      &lt;textarea cols=&quot;30&quot; rows=&quot;8&quot; name=&quot;message&quot; id=&quot;message&quot; placeholder=&quot;Tattoo description, where, size, placement&quot; required&gt;&lt;/textarea&gt;&lt;br&gt;
                                      &lt;br&gt;
                                      &lt;label for=&quot;userfile[]&quot;&gt;Upload Files &lt;a style=&quot;font-size:0.8em;opacity:0.7;&quot; title=&quot;20MB Maximum. Holding the ctrl key will allow selection of multiple files&quot;&gt;[?]&lt;/a&gt;&lt;/label&gt;
  
                                      &lt;input type=&quot;hidden&quot; name=&quot;MAX_FILE_SIZE&quot; value=&quot;20000000&quot;&gt;
                                      &lt;input id=&quot;file&quot; type=&quot;file&quot; name=&quot;userfile[]&quot; multiple=&quot;multiple&quot; onchange=&quot;javascript:updateList()&quot;&gt;
                                      &lt;div id=&quot;filelist&quot;&gt;&lt;/div&gt;
  
                                      &lt;ul&gt;
                                          &lt;li&gt;Upload a photo of the location of your body where your tattoo will be placed.&lt;/li&gt;
                                          &lt;li&gt;Upload any reference photos you may have&lt;/li&gt;
                                      &lt;/ul&gt;
  
                                      &lt;p class=&quot;contact-submit-holder&quot;&gt;
                                          &lt;input class=&quot;agree&quot; type=&quot;submit&quot; value=&quot;Submit Request&quot;&gt;
                                      &lt;/p&gt;
                                  &lt;/form&gt;
  ```
  </code></pre>