2016-07-03 7 views
2

PHP와 컬을 사용하여 실시간 메일 서버에서 완전한 응답을 얻으려고합니다. pop3 프로토콜로 연결하려고했지만 작동하지 않습니다.PHP 큐로 outlook.com 메일 서버에 연결

코드 목록 1 :

<?php 
    // create curl resource 
    $curl = curl_init(); 

    if($curl) { 
     /* Set username and password */ 
     curl_setopt($curl, CURLOPT_USERNAME, "[email protected]"); 
     curl_setopt($curl, CURLOPT_PASSWORD, "password"); 

     curl_setopt($curl, CURLOPT_URL, "pop3://pop3.live.com"); 
     curl_setopt($curl, CURLOPT_PORT, 995); 

     curl_setopt($curl, CURLOPT_USE_SSL,CURLUSESSL_ALL); 

     curl_setopt($curl, CURLOPT_CAINFO, "./certificate.pem"); 

     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); 
?> 

이 코드를 사용 (프로토콜 POP3 포함). 표준 출력은 클라이언트가 포트 995에서 성공적으로 연결되었음을 알려줍니다. 그러나 응답을 읽지 못합니다.

응답 독서는

닫기 연결 0

실패하지만 HTTPS 프로토콜 대신에 (같은 코드)에 POP3를 사용할 때 나는 부분 반응을 얻을. 그것은 전체 응답 헤더처럼 보입니다. 적어도 마지막 텍스트 다음에 두 개의 새로운 라인을 출력하기 때문에 보이는 것처럼 보입니다.

수락 : */*

답변

1

컬는 SSL을 통한 보안 POP에 대해 서로 다른 프로토콜 식별자를 가지고있다.

pop3:// 대신 pop3s://을 시도하면 답변을 되 찾을 수 있습니다.

* Rebuilt URL to: pop3s://pop3.live.com/ 
* Hostname was NOT found in DNS cache 
* Trying 134.170.170.231... 
* Connected to pop3.live.com (134.170.170.231) port 995 (#0) 
* successfully set certificate verify locations: 
* CAfile: none 
    CApath: /etc/ssl/certs 
* SSL connection using ECDHE-RSA-AES256-SHA 
* Server certificate: 
* subject: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation; CN=*.hotmail.com 
* start date: 2015-12-15 22:26:11 GMT 
* expire date: 2016-12-15 22:26:11 GMT 
* subjectAltName: pop3.live.com matched 
* issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign Organization Validation CA - SHA256 - G2 
* SSL certificate verify ok. 
< +OK DUB006-POP162 POP3 server ready 
> CAPA 
< -ERR unrecognized command 
> USER [email protected] 
< +OK password required 
> PASS pass 
< +OK Logged in. 
> LIST 
< +OK 5226 messages: 
string(59927) "1 1830 
2 69432 
3 2751 
4 2726 
5 18506 
6 2868 
7 4636 
8 1955 
9 2242 
10 3697