title: Configuring PHPMailer on Siteground shared hosting plan
body: <p>I am stuck trying to make PHPMailer to work with my website hosted on Siteground.</p>
  <p>I installed it by composer via PuTTY, everything looking fine so far:</p>
  <p><a href="https://i.stack.imgur.com/EDHKd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EDHKd.png" alt="PuTTY console screenshot" /></a></p>
  <p>But when I try to test it, I can't get it to work properly.</p>
  <p>Here is a sample of my testing code:</p>
  <pre><code>&lt;?php
  use PHPMailer\PHPMailer\PHPMailer;
  use PHPMailer\PHPMailer\SMTP;
  use PHPMailer\PHPMailer\Exception;
  
  require 'vendor/autoload.php';
  
  $mail = new PHPMailer(true);
  
  try {
      $mail-&gt;SMTPDebug = SMTP::DEBUG_SERVER;
      $mail-&gt;isSMTP();
      $mail-&gt;Host       = '**HOST**';
      $mail-&gt;SMTPAuth   = true;
      $mail-&gt;Username   = '**MAILACCOUNT**';
      $mail-&gt;Password   = '**PASSWORD';
      $mail-&gt;SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
      $mail-&gt;Port       = 465;
  
      $mail-&gt;setFrom('**MAILACCOUNT**', 'Mailer');
      $mail-&gt;addAddress('**TESTMAILRECIPIENT', 'test');
  
      $mail-&gt;isHTML(true);
      $mail-&gt;Subject = 'Here is the subject';
      $mail-&gt;Body    = 'This is the HTML message body &lt;b&gt;in bold!&lt;/b&gt;';
      $mail-&gt;AltBody = 'This is the body in plain text for non-HTML mail clients';
  
      $mail-&gt;send();
      echo 'Message has been sent';
  }
  catch (Exception $e) {
      echo &quot;Message could not be sent. Mailer Error: {$mail-&gt;ErrorInfo}&quot;;
  }
  ?&gt;
  </code></pre>
  <p>Which is a modified version of the template PHPMailer provides on their github.</p>
  <p>All of my credentials are good (host, mail account, password). I tried with different ports (25, 587) and as per Siteground the good port for SMTP is <strong>465</strong>. But nothing work. The <strong>try catch block</strong> does not even catch any error, sometimes depending of what I try my webpage stays blank, or return a <strong>HTMLERROR 500</strong>.</p>
  <p>I tried to reach out their technical support but they don't seem to have a clue about anything. They sent me the link to the <a href="https://github.com/PHPMailer/PHPMailer" rel="nofollow noreferrer">PHPMailer github</a>, telling me to follow the tutorial.</p>
  <p>There is absolutely no documentation about using this PHP library with their services. I have been searching for 2 days now. It seems they have changed their interface, as many - if not all - of their tutorials are for an older version of their cPanel.</p>
  <p>Maybe it could have something to do with <strong>SPF and DKIM protocols</strong>? DKIM is active on my account, SPF I have absolutely no clue what to do with this.</p>
  <p>Here is my generated SPF record, if ever you need to know:</p>
  <p><code>v=spf1 +a +mx +ip4:**MYIP** include:_spf.mailspamprotection.com ~all</code></p>
  <p>I tried many online tutorials and adapted them to my needs with Siteground, with no success.</p>
  <p>Is there anybody used to their system and could help me getting this to work?</p>
  <p>I use a shared hosted plan, if it helps. They use Linux servers.</p>
  <p>Thank you very much!</p>