title: How to fix: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
body: <p>I am currently working on cygwin.
  I was trying to send and email through phpmailer using my gmail account and the following script (obtained online, then hacked):</p>
  
  <pre><code> &lt;?php  
   require 'phpmailer/PHPMailerAutoload.php';
      $mail = new PHPMailer(true); 
      try {
          $mail-&gt;ISSMTP();
          $mail-&gt;Host='smtp.gmail.com';
          $mail-&gt;SMTPDebug = 1;
          $mail-&gt;SMTPAuth = true;
          $mail-&gt;SMTPSecure = "tls";
          $mail-&gt;SMTPOptions = array(
            'ssl' =&gt; array(
              'verify_peer' =&gt; true,
              'verify_peer_name' =&gt; false,
              'allow_self_signed' =&gt; true
            )
          );
          $mail-&gt;Port = 587;
          $mail-&gt;Username = "myemail@gmail.com";
          $mail-&gt;Password = "MyGooglePassword";
          $mail-&gt;setFrom('myemail@gmail.com', 'my name1');
          $mail-&gt;addAddress('anotheremail@email.fr', 'my name2');
          $mail-&gt;Subject = 'PHPMailer Exceptions test';
          $mail-&gt;Body = "Hi, This is the HTML BODY "; //HTML Body
          $mail-&gt;AltBody = 'This is a plain-text message body';
          $mail-&gt;send();
          echo "Message sent!"; 
      } catch (phpmailerException $e) {
          echo $e-&gt;errorMessage(); //Pretty error messages from PHPMailer 
      } catch (Exception $e) {
          echo $e-&gt;getMessage(); 
      }
  </code></pre>
  
  <p>I have seen multiple solutions on stack overflow, but I haven't found any telling how to properly self sign my localhost so that I would be able to avoid this error message:</p>
  
  <pre><code>PHP Warning:  stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
  error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /usr/share/pear/phpmailer/class.smtp.php on line 346
  2015-11-30 08:47:15     SMTP Error: Could not connect to SMTP host.
  2015-11-30 08:47:15     CLIENT -&gt; SERVER: QUIT
  2015-11-30 08:47:15     SMTP ERROR: QUIT command failed
  </code></pre>
  
  <p>I have also tried resolving the issues by setting 'verify_peer' to false at "$mail->SMTPOptions" (as recommended in: <a href="https://stackoverflow.com/questions/26827192/phpmailer-ssl3-get-server-certificatecertificate-verify-failed">PHPMailer - SSL3_GET_SERVER_CERTIFICATE:certificate verify failed</a>), but when I do that, my gmail account refuse to cooperate saying that the signing attempt does not meet modern security standard!!</p>
  
  <p>Please let me know if there is a proper tutorial that would allow me to properly set my ssl and have the email successfuly sent with the proper verifications.
  Here is below a link to the gmail message: <a href="https://i.stack.imgur.com/r0Bk1.png" rel="nofollow noreferrer">Gmail - sign in attempt prevented</a></p>