title: phpmailer error SMTP Error: Data not accepted
body: <p>I've searched all the solutions on StackOverflow for this and tried everything but can't seem to fix this error. It seems to be intermittent as occasionally it works and I receive the email and attachments into my MSOutlook inbox making this even more frustrating.</p>
  <p>I'm using phpmailer to send image files (jpg)</p>
  <p>Here's mail-send.php</p>
  <pre><code>&lt;?php
  require('phpmailer/class.phpmailer.php');
  
  $mail = new PHPMailer();
  $mail-&gt;IsSMTP();
  $mail-&gt;SMTPDebug = 0;
  $mail-&gt;SMTPAuth = TRUE;
  $mail-&gt;SMTPSecure = &quot;ssl&quot;;
  $mail-&gt;Port     = 465;
  $mail-&gt;Username = &quot;NAME@DOMAIN.ORG&quot;;
  $mail-&gt;Password = &quot;PASSWORD&quot;;
  $mail-&gt;Host     = &quot;mail.uk2.net&quot;;
  $mail-&gt;Mailer   = &quot;smtp&quot;;
  $mail-&gt;SetFrom($_POST[&quot;userEmail&quot;], $_POST[&quot;userName&quot;]);
  $mail-&gt;AddReplyTo($_POST[&quot;userEmail&quot;], $_POST[&quot;userName&quot;]);
  $mail-&gt;AddAddress(&quot;NAME@DOMAIN.ORG&quot;);   
  $mail-&gt;Subject = $_POST[&quot;subject&quot;];
  $mail-&gt;WordWrap   = 80;
  $mail-&gt;MsgHTML($_POST[&quot;content&quot;]);
  
  foreach ($_FILES[&quot;attachment&quot;][&quot;name&quot;] as $k =&gt; $v) {
      $mail-&gt;AddAttachment( $_FILES[&quot;attachment&quot;][&quot;tmp_name&quot;][$k], $_FILES[&quot;attachment&quot;][&quot;name&quot;][$k] );
  }
  
  $mail-&gt;IsHTML(true);
  
  if(!$mail-&gt;Send()) {
      echo &quot;&lt;p class='error'&gt;There was a problem sending your photographs. Please try again later via your 'My Dashboard' homepage.&lt;/p&gt;&quot;;
  } else {
      echo &quot;&lt;p class='success'&gt;&lt;strong&gt;Your photograph/s have been submitted.&lt;/strong&gt;&lt;br&gt;Thank you!&lt;/p&gt;&quot;;
  }   
  ?&gt;
  </code></pre>
  <p>and here's the html form in send.php</p>
  <pre><code>&lt;form id=&quot;sendpics&quot; action=&quot;&quot; method=&quot;post&quot; enctype='multipart/form-data'&gt;
              &lt;input name=&quot;userName&quot; type=&quot;text&quot; id=&quot;userName&quot; value=&quot;&lt;?php echo $row['rFullName']; ?&gt;&quot;&gt;
              &lt;input name=&quot;userEmail&quot; type=&quot;text&quot; id=&quot;userEmail&quot; value=&quot;&lt;?php echo $row['rEmail']; ?&gt;&quot;&gt;
              &lt;input name=&quot;subject&quot; type=&quot;text&quot; id=&quot;subject&quot; value=&quot;Photos for CBC Record ID &lt;?php echo htmlentities($row['rID']); ?&gt;&quot;&gt;
                  
              &lt;textarea name=&quot;content&quot; id=&quot;content&quot; rows=&quot;6&quot;&gt;
              &lt;?php echo htmlentities($row['rFullName']); ?&gt; has submitted a record.
              &lt;br&gt;Photos relating to this record are attached.
              &lt;br&gt;Record ID#: &lt;?php echo htmlentities($row[&quot;rID&quot;]); ?&gt;
              &lt;br&gt;Location: &lt;?php echo htmlentities($row['rLocation']); ?&gt;
              &lt;br&gt;Date: &lt;?php echo htmlentities($row['rDate']); ?&gt;
              &lt;br&gt;&lt;a href='URL?rID=&lt;?php echo htmlentities($row[&quot;rID&quot;]); ?&gt;'&gt;Click this link&lt;/a&gt;* to view this record.&lt;/textarea&gt;
                                
              &lt;div class=&quot;form-group has-feedback&quot;&gt;
                  &lt;input class=&quot;form-control&quot; type=&quot;file&quot; name=&quot;attachment[]&quot; multiple=&quot;multiple&quot; accept=&quot;.jpg,.jpeg&quot;&gt;
              &lt;/div&gt;
                  
              &lt;div id=&quot;loader-icon&quot; style=&quot;display: none;&quot; class=&quot;pull-right&quot;&gt;&lt;img src=&quot;LoaderIcon.gif&quot; /&gt;&lt;/div&gt;&lt;input type=&quot;submit&quot; class=&quot;btn btn-sm btn-default&quot; value=&quot;SEND PHOTOS&quot; /&gt;
                  
  &lt;/form&gt;
  &lt;div id=&quot;mail-status&quot;&gt;&lt;/div&gt;
  </code></pre>
  <p>and the script in the head of send.php</p>
  <pre><code>&lt;script src=&quot;jquery-3.2.1.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
  $(document).ready(function (e){
      $(&quot;#sendpics&quot;).on('submit',(function(e){
          e.preventDefault();
          $('#loader-icon').show();
          var valid;  
          valid = validateContact();
          if(valid) {
              $.ajax({
              url: &quot;mail-send.php&quot;,
              type: &quot;POST&quot;,
              data:  new FormData(this),
              contentType: false,
              cache: false,
              processData:false,
              success: function(data){
                  $(&quot;#mail-status&quot;).html(data);
                  $('#loader-icon').hide();
              },
              error: function(){}             
          });
      }
      }));
  });
  &lt;/script&gt;
  </code></pre>
  <p>Any phpmailer genius out there know what I'm doing wrong to get</p>
  <blockquote>
  <p>SMTP Error: Data not accepted'</p>
  </blockquote>
  <p>most but not all of the time? Yesterday it seemed to be working fine. Today the only change on the server is that we now have an SSL certificate. Could this be the cause? If so, the fix?? We are on UK2.net hosting.</p>
  <p>Huge thanks in advance.
  Steve</p>