Answers.Body: <p>The fix for the specific error was to switch the port number within email settings to 2525 - that took a lot of finding out, but crucially avoids hacking PHPMailer.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-04T09:56:24.157Z
Answers.LastActivityDate: 2017-05-04T09:56:24.157Z
Answers.UserDisplayName: Clive Portman
Body: <p>I'm using a third-party email service called SendGrid to send email but am coming up with what I think is a server issue with the SSL. A temporary fix is to edit a line similar to this in a PHPMailer example:</p>
  
  <pre><code>$mail-&gt;SMTPOptions = array(
      'ssl' =&gt; array(
          'verify_peer' =&gt; false,
          'verify_peer_name' =&gt; false,
          'allow_self_signed' =&gt; true
      )
  );
  </code></pre>
  
  <p>But Craft doesn't use anything that resembles that to me.I want to try hacking the core to see if I can get a temporary fix up but can't find where to put it, despite scouring <code>EmailService.php</code>. Can anyone point me to the function where I'd add these details? </p>
  
  <p>Here's the error,  by the way:</p>
  
  <pre><code>stream_socket_enable_crypto(): Peer certificate CN=`#################' did not match expected CN=`smtp.sendgrid.net' (/home/################/craft/app/vendor/phpmailer/phpmailer/class.smtp.php:367
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-27T07:37:56.983Z
Comments.Text: The file your looking for is './craft/app/vendor/phpmailer/phpmailer/class.phpmailer.php' look for the line with `public $SMTPOptions = array();`
Comments.UserDisplayName: Regan Lawton
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-27T08:36:48.287Z
Comments.Text: Thank you - I'd spent some time in that file but will return to that line. I can't see Craft passing anything to that array, can you?
Comments.UserDisplayName: Clive Portman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-04-28T00:41:49.370Z
Comments.Text: The file is setting defaults that public array is used elsewhere. By setting that array with the info in your question you will prevent the Peer Certificate error your getting.
Comments.UserDisplayName: Regan Lawton
Tags: <emails>
Title: stream_socket_enable_crypto() error when sending email via SMTP
ThreadText: # stream_socket_enable_crypto() error when sending email via SMTP
  
  (Asked by: username_0 on 2017-04-26)
  
  I'm using a third-party email service called SendGrid to send email but am coming up with what I think is a server issue with the SSL. A temporary fix is to edit a line similar to this in a PHPMailer example:
  
  ```
  $mail->SMTPOptions = array(
      'ssl' => array(
          'verify_peer' => false,
          'verify_peer_name' => false,
          'allow_self_signed' => true
      )
  );
  
  ```
  
  But Craft doesn't use anything that resembles that to me.I want to try hacking the core to see if I can get a temporary fix up but can't find where to put it, despite scouring `EmailService.php`. Can anyone point me to the function where I'd add these details?
  
  Here's the error, by the way:
  
  ```
  stream_socket_enable_crypto(): Peer certificate CN=`#################' did not match expected CN=`smtp.sendgrid.net' (/home/################/craft/app/vendor/phpmailer/phpmailer/class.smtp.php:367
  
  ```
  
  **Tags:** emails
  
  > **Comments:**
  > **username_1**: The file your looking for is './craft/app/vendor/phpmailer/phpmailer/class.phpmailer.php' look for the line with `public $SMTPOptions = array();`  
  > **username_0**: Thank you - I'd spent some time in that file but will return to that line. I can't see Craft passing anything to that array, can you?  
  > **username_1**: The file is setting defaults that public array is used elsewhere. By setting that array with the info in your question you will prevent the Peer Certificate error your getting.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-05-04. Score: 3 | Accepted answer
  
  The fix for the specific error was to switch the port number within email settings to 2525 - that took a lot of finding out, but crucially avoids hacking PHPMailer.
  
  
  ---
  
  