Connect to outlook.com mail server with PHP cURL
<p>I am trying to get an complete answer from the live mail server using php and curl. I tried to connect with pop3 protocol but it's not working.</p>
<p><strong>code-listing 1:</strong></p>
<pre><code>&lt;?php 
    // create curl resource 
    $curl = curl_init(); 
    
    if($curl) {
        /* Set username and password */ 
        curl_setopt($curl, CURLOPT_USERNAME, &quot;example@outlook.com&quot;);
        curl_setopt($curl, CURLOPT_PASSWORD, &quot;password&quot;);
        
        curl_setopt($curl, CURLOPT_URL, &quot;pop3://pop3.live.com&quot;);
        curl_setopt($curl, CURLOPT_PORT, 995);
        
        curl_setopt($curl, CURLOPT_USE_SSL,CURLUSESSL_ALL);
        
        curl_setopt($curl, CURLOPT_CAINFO, &quot;./certificate.pem&quot;);
        
        curl_setopt($curl, CURLOPT_VERBOSE, true);
        
        //return the transfer as a string 
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);

        // $output contains the output string 
        $output = curl_exec($curl);
    }
    
    echo $output;

    curl_close($curl); 
?&gt;
</code></pre>
<p>When I use this code (with <strong>pop3</strong> protocol). the standard output tells me the client connected successfully on port 995. But fails to read the response.</p>
<blockquote>
<p>response reading failed</p>
<p>Closing connection 0</p>
</blockquote>
<p>but when I use <strong>https</strong> protocol instead of <strong>pop3</strong> (on the same code) I get a partial response. It looks like the entire response header, at least that's what it looks like since it outputs two new lines after the last text.</p>
<blockquote>
<p>Accept: */*</p>
</blockquote>