title: PHP Mailer - 454 TLS connection failed
body: <p>On my page I have a contact form which uses PHP Mailer.
  At the beginning, for testing purposes only, I used it with my Gmail account. Everything worked like a charm. Then I decided to change the e-mail service from Gmail to one which comes from my hosting provider. Then the problems have started. Every time I attempt to send an email, an exception occurs:</p>
  
  <pre><code>2020-05-13 20:53:44 CLIENT -&gt; SERVER: STARTTLS
  2020-05-13 20:53:44 SERVER -&gt; CLIENT: 220 ready for tls
  SMTP Error: Could not connect to SMTP host.
  2020-05-13 20:53:44 CLIENT -&gt; SERVER: QUIT
  2020-05-13 20:53:44 SERVER -&gt; CLIENT: 454 TLS connection failed: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure (#4.3.0)
  2020-05-13 20:53:44 SMTP ERROR: QUIT command failed: 454 TLS connection failed: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure (#4.3.0)
  </code></pre>
  
  <p>This is my code for sending an e-mail:</p>
  
  <pre><code>&lt;?php
  
      use PHPMailer\PHPMailer\PHPMailer;
      use PHPMailer\PHPMailer\Exception;
      use PHPMailer\PHPMailer\SMTP;
  
      require 'PHPMailer.php';
      require 'SMTP.php';
      require 'Exception.php';
  
      class Mailer
      {
          private $mail;
  
          public function __construct($host, $user, $password, $port = 587)
          {
              $this-&gt;mail = new PHPMailer();
              try
              {
                  $this-&gt;mail-&gt;SMTPDebug = SMTP::DEBUG_SERVER;  
                  $this-&gt;mail-&gt;CharSet    = "UTF-8";
                  $this-&gt;mail-&gt;isSMTP();
                  $this-&gt;mail-&gt;Host       = $host;
                  $this-&gt;mail-&gt;SMTPAuth   = true;
                  $this-&gt;mail-&gt;SMTPSecure = 'ssl';
                  $this-&gt;mail-&gt;Username   = $user;
                  $this-&gt;mail-&gt;Password   = $password;
                  $this-&gt;mail-&gt;SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
                  $this-&gt;mail-&gt;Port       = $port;
              }
              catch(Exception $e)
              {
                  echo "Exception: " . $e;
              }
          }
  
          public function Send($from, $alias, $to, $subject, $body, $cc)
          {
              try
              {
                  $this-&gt;mail-&gt;setFrom($from, $alias);
                  $this-&gt;mail-&gt;addAddress($to);
  
                  $this-&gt;mail-&gt;isHTML(true);
                  $this-&gt;mail-&gt;Subject = $subject;
                  $this-&gt;mail-&gt;Body    = $body;
  
                  if($cc !== '')
                  {
                      $this-&gt;mail-&gt;AddCC($cc);
                  }
  
                  if(!$this-&gt;mail-&gt;send())
                  {
                      die($this-&gt;mail-&gt;ErrorInfo);
                  }
  
                  return true;
              }
              catch (Exception $e)
              {
                  return false;
              }
          }
  </code></pre>
  
  <p>I suppose I configure PHP Mailer wrongly when it comes to TLS/SSL, as I am pretty newbie to this. It may be an expedient information that my webpage uses TLS 1.3 encryption</p>