Get error SSL operation failed with code 1 when using swiftmailer to send an email in yii2
<p>I'm trying to send a email by using the included mailer in yii2. But getting this error when I submit the email. </p>

<pre><code>stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
</code></pre>

<p>I not sure is that the setup issue with my localhost.</p>

<p>Following is my mailer config code set in common/config/main-local.php</p>

<pre><code> 'mailer' =&gt; [
    'class' =&gt; 'yii\swiftmailer\Mailer',
    'transport' =&gt; [
        'class' =&gt; 'Swift_SmtpTransport',
        'host' =&gt; 'smtp-mail.outlook.com',
        'username' =&gt; 'myMail@outlook.com',
        'password' =&gt; 'myPassword',
        'port' =&gt; '587',
        'encryption' =&gt; 'tls',
    ],
]
</code></pre>

<p>Following is the code I trying to submit an email</p>

<pre><code>$model = new email;
if($model-&gt;load(Yii::$app-&gt;request-&gt;post(),'email') &amp;&amp; $model-&gt;validate()){

    if(count($model-&gt;htmlBody)&gt;=1){
    Yii::$app-&gt;mailer-&gt;compose()
         -&gt;setFrom("myPass@outlook.com")
         -&gt;setTo($model-&gt;receiver)
         -&gt;setSubject($model-&gt;subject)
         -&gt;send();
         Yii::$app-&gt;session-&gt;setFlash("msg","A mail has been sent");
    }
    else{
          Yii::$app-&gt;mailer-&gt;compose()
         -&gt;setFrom("imotthegod@outlook.com")
         -&gt;setTo($model-&gt;receiver)
         -&gt;setSubject($model-&gt;subject)
         -&gt;send();
         Yii::$app-&gt;session-&gt;setFlash("msg","A mail has been sent");

    }
}
return $this-&gt;render("email",['model'=&gt;$model]);
</code></pre>