title: My form in phpmailer() only allow send mails from a mail with own domain
body: <p>I have this code and it's a problem because it works when I am sending mails when I am specifing a mail with own domain in the form. But it doesn't work if I using a gmail or Yahoo mail. </p>
  
  <p>This is the code I'm using on PHPMailer:</p>
  
  <pre><code>&lt;?php
  error_reporting(E_ALL);
  ini_set('display_errors', '1');
  require_once 'phpmailer/PHPMailerAutoload.php';
  
  if (isset($_POST['inputName']) &amp;&amp; isset($_POST['inputEmail']) &amp;&amp; isset($_POST['inputSubject']) &amp;&amp; isset($_POST['inputMessage'])) {
  
      //check if any of the inputs are empty
      if (empty($_POST['inputName']) || empty($_POST['inputEmail']) || empty($_POST['inputSubject']) || empty($_POST['inputMessage'])) {
          $data = array('success' =&gt; false, 'message' =&gt; 'Please fill out the form completely.');
          echo json_encode($data);
          exit;
      }
  
      //create an instance of PHPMailer
      $mail = new PHPMailer();
      $mail-&gt;IsSMTP();
      $mail-&gt;SMTPAuth = true;
      $mail-&gt;Host = "mail.example.com"; // SMTP a utilizar. Por ej. smtp.elserver.com
      $mail-&gt;Username = "contacto@example.com"; // Correo completo a utilizar
      $mail-&gt;Password = "xxx"; // Contraseña
      $mail-&gt;Port = 25; // Puerto a utilizar
  
      $mail-&gt;From = $_POST['inputEmail'];
      $mail-&gt;FromName = $_POST['inputName'];
      $mail-&gt;AddAddress('contacto@example.net'); //recipient 
      $mail-&gt;Subject = $_POST['inputSubject'];
      $mail-&gt;Body = "Name: " . $_POST['inputName'] . "\r\n\r\nMessage: " . stripslashes($_POST['inputMessage']);
      $mail-&gt;CharSet = 'UTF-8';
  
      if (isset($_POST['ref'])) {
          $mail-&gt;Body .= "\r\n\r\nRef: " . $_POST['ref'];
      }
  
      if(!$mail-&gt;send()) {
          $data = array('success' =&gt; false, 'message' =&gt; 'El mensaje no se ha enviado: ' . $mail-&gt;ErrorInfo);
          echo json_encode($data);
          exit;
      }
  
      $data = array('success' =&gt; true, 'message' =&gt; '¡Gracias! Hemos recibido tu mensaje.');
      echo json_encode($data);
  
  } else {
  
      $data = array('success' =&gt; false, 'message' =&gt; 'Favor de llenar los campos correctamente.');
      echo json_encode($data);
  
  }
  </code></pre>