title: PHPMailer: blocked by Strato hosting?
body: <p>After having spent endless hours reading and trying different solutions, and checked the topics in StackOverflow related to PHPMailer, I am giving up... I hope someone could help me on this, I would really appreciate it.<br><br></p>
  <p>I am using PHPMailer to send an automatic email when the user requests it via a form.</p>
  <h1>CASES</h1>
  <p>These are the different scenarios that I am facing:<br></p>
  <p><strong>A) From Localhost</strong> -&gt; Everything works<br></p>
  <ol>
  <li>PHPMailer in Localhost sending an email from a gmail account (smtp.gmail.com) to the user -&gt; <strong>WORKS</strong><br></li>
  <li>Same, but from a hotmail account (smtp.live.com) -&gt; <strong>WORKS</strong><br></li>
  </ol>
  <p><strong>B)</strong> Exactly the same folders/files uploaded into my <strong>Strato hosting space</strong>:<br></p>
  <ol>
  <li>From the same gmail account that worked in the localhost -&gt; The webpage freezes<br></li>
  <li>From the same hotmail account that worked in the localhost -&gt; The webpage freezes<br></li>
  <li>From a Strato email account (smtp.strato.com) -&gt; <strong>WORKS</strong><br><br></li>
  </ol>
  <p>When I say that the webpage freezes, I refer to the fact that the wepage keeps loading forever without showing any kind of error, despite having the option <strong>SMTPDebug = SMTP::DEBUG_SERVER</strong> activated, so that, it is very difficult to debug.<br>
  Actually, when that happens, the whole website gets irresponsive for (roughly) a couple of minutes.</p>
  <h1>ADDITIONAL INFO</h1>
  <p>PHP Version 7.3<br>
  PHPMailer Compatible with PHP &gt;= 5.5<br>
  PHPMailer <strong>troubleshooting from GitHub</strong>-&gt; I checked the whole list except the actions related to certificates, as I did not find the way to do it.<br>
  <strong>Stackoverflow</strong> -&gt; I went through the whole list of PHPMailer-related topics. I did not find the solution.<br><br></p>
  <p><strong>Some especific actions that I tried</strong> suggested in the troubleshooting:<br></p>
  <ul>
  <li>Host = gethostbyname('smtp.gmail.com')<br></li>
  <li>I tried both PHPMailer::ENCRYPTION_STARTTLS and PHPMailer::ENCRYPTION_SMTPS<br></li>
  <li>Ports: 465 for ssl, 587 for tls, 25 and 2525.<br></li>
  <li>check that openssl extension is enabled<br><br></li>
  </ul>
  <p><strong>UPDATE 6th Oct 2020</strong>
  Strato has clarified that they do not block these kind of requests, hence, the initial guess is not the cause.</p>
  <blockquote>
  <p><strong>Reasonable guess?</strong>
  This is telling me that Strato might be blocking my website from
  requesting to external servers, however, I am not a professional of
  this, so this is just a logical guess.<br></p>
  </blockquote>
  <p>Many thanks to you all in advance.
  If I missed the solution somewhere, please do feel free to just redirct me to the article/site.
  Thanks!</p>
  <h1>CODE</h1>
  <pre><code>&lt;?php
  use PHPMailer\PHPMailer\PHPMailer;
  use PHPMailer\PHPMailer\SMTP;
  use PHPMailer\PHPMailer\Exception;
  ini_set('display_errors', true);
  
  require_once '../vendor/PHPMailer/src/Exception.php';
  require_once '../vendor/PHPMailer/src/PHPMailer.php';
  require_once '../vendor/PHPMailer/src/SMTP.php';
  if (extension_loaded('openssl')) {
      echo 'openssl extension loaded.';}
  
  $mail = new PHPMailer(true);
  $mail-&gt;CharSet =  &quot;utf-8&quot;;
  $mail-&gt;IsSMTP();
  $mail-&gt;SMTPAutoTLS = false;
  $mail-&gt;SMTPAuth = true;                  
  $mail-&gt;Username='xxxxx';
  $mail-&gt;Password = &quot;xxxxx&quot;;
  $mail-&gt;SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
  $mail-&gt;SMTPOptions = [
      'ssl' =&gt; [
          'verify_peer' =&gt; false,
          'verify_peer_name' =&gt; false,
          'allow_self_signed' =&gt; true
      ]
      ];
  //$mail-&gt;Host = &quot;smtp.strato.com&quot;;
  //$mail-&gt;Host = gethostbyname('smtp.gmail.com');
  $mail-&gt;Host = &quot;smtp.gmail.com&quot;;
  
  // set the SMTP port for the GMAIL server
  $mail-&gt;Port = &quot;587&quot;;
  $mail-&gt;SMTPDebug = SMTP::DEBUG_SERVER;
  $mail-&gt;From='xxxxxx@gmail.com';
  $mail-&gt;FromName='xxxx';
  $mail-&gt;AddAddress($email, '');
  $mail-&gt;Subject  =  'some text';
  $mail-&gt;IsHTML(true);
  $mail-&gt;Body    = 'more text';
  // *************************** The server hangs right here ***********************
  if($mail-&gt;Send())
  {
      echo &quot;nice&quot;;
  }
  else
  {
      echo &quot;Mail Error - &gt;&quot;.$mail-&gt;ErrorInfo;
  }
  ?&gt;
  </code></pre>