title: PHPMailer error - SMTP Error: Data not accepted
body: <p>I have done a contact form and obviously I would like to receive a confirmation email when a user fill out this form on my website.</p>
  
  <p>I'm using PHPMailer. When I test the code on my computer as localhost, everything works fine and confirmation message is received properly.</p>
  
  <p>Here you are the PHP script:</p>
  
  <pre><code>&lt;?php
  
  $Name= $_POST['Name'];
  $Email = $_POST['Email'];
  $Message = $_POST['Message'];
  
  if ($Name=='' || $Email=='' || $Message==''){
  
  echo "&lt;script&gt;alert('Please fill out mandatory fields');location.href ='javascript:history.back()';&lt;/script&gt;";
  
  }else{
  
  require("archivosformulario/class.phpmailer.php");
  $mail = new PHPMailer();
  
  $mail-&gt;From     = $Email;
  $mail-&gt;FromName = $Name; 
  $mail-&gt;AddAddress("myemail@gmail.com");
  
  
  $mail-&gt;WordWrap = 50; 
  $mail-&gt;IsHTML(true);     
  $mail-&gt;Subject  =  "Contact Form";
  $mail-&gt;Body     =  "Name: $name \n&lt;br /&gt;".    
  "Email: $Email \n&lt;br /&gt;".    
  "Message: $Message\n&lt;br /&gt;";
  
  
  // SMTP Server
  
  $mail-&gt;IsSMTP(); 
  $mail-&gt;SMTPDebug  = 2;    
  $mail-&gt;Host = "smtp.gmail.com";
  $mail-&gt;SMTPAuth = true; 
  $mail-&gt;Port = 465;
  $mail-&gt;SMTPSecure = "ssl"; 
  $mail-&gt;Username = "myemail@gmail.com"; 
  $mail-&gt;Password = "mypassword"; 
  
  if ($mail-&gt;Send())
  echo "&lt;script&gt;alert('We have received your message. We will contact you shortly.');location.href ='javascript:history.back()';&lt;/script&gt;";
  else
  echo "&lt;script&gt;alert('Error');location.href ='javascript:history.back()';&lt;/script&gt;";
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>The problem is when I upload this PHP script on a web hosting (i.e 123-reg.co.uk), it doesn´t work. </p>
  
  <p>Error message: </p>
  
  <pre><code>SMTP Error: Data not accepted
  </code></pre>
  
  <p>Here you are the PHP script:</p>
  
  <pre><code>&lt;?php
  
  $Name= $_POST['Name'];
  $Email = $_POST['Email'];
  $Message = $_POST['Message'];
  
  if ($Name=='' || $Email=='' || $Message==''){
  
  echo "&lt;script&gt;alert('Please fill out mandatory fields');location.href ='javascript:history.back()';&lt;/script&gt;";
  
  }else{
  
  require("archivosformulario/class.phpmailer.php");
  $mail = new PHPMailer();
  
  $mail-&gt;From     = $Email;
  $mail-&gt;FromName = $Name; 
  $mail-&gt;AddAddress("email@mydomainat123-reg.com");
  
  
  $mail-&gt;WordWrap = 50; 
  $mail-&gt;IsHTML(true);     
  $mail-&gt;Subject  =  "Contact Form";
  $mail-&gt;Body     =  "Name: $name \n&lt;br /&gt;".    
  "Email: $Email \n&lt;br /&gt;".    
  "Message: $Message\n&lt;br /&gt;";
  
  
  // SMTP Server
  
  $mail-&gt;IsSMTP(); 
  $mail-&gt;SMTPDebug  = 2;    
  $mail-&gt;Host = "smtp.123-reg.co.uk";
  $mail-&gt;SMTPAuth = true; 
  $mail-&gt;Port = 25;
  $mail-&gt;Username = "email@mydomainat123-reg.com"; 
  $mail-&gt;Password = "password"; 
  
  if ($mail-&gt;Send())
  echo "&lt;script&gt;alert('We have received your message. We will contact you shortly.');location.href ='javascript:history.back()';&lt;/script&gt;";
  else
  echo "&lt;script&gt;alert('Error');location.href ='javascript:history.back()';&lt;/script&gt;";
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>I have tried uploading and executing this PHP script from another free web hosting but it was to not avail.</p>
  
  <p>I'm kind of new in PHP, especially in dealing with mail functions.</p>
  
  <p>What can be the reason? Any additional help would be appreciated. </p>
  
  <p>Thanks in advance for your help.</p>