Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
与cURL相当的PHP;“用户界面”;用于IMAP_Php_Curl_Imap - Fatal编程技术网

与cURL相当的PHP;“用户界面”;用于IMAP

与cURL相当的PHP;“用户界面”;用于IMAP,php,curl,imap,Php,Curl,Imap,我想知道,在发送IMAP请求时,是否有办法选择要使用的IP 例如,我有一个具有4个ip地址的服务器,我想将第二个ip地址用于IMAP。我在寻找一些东西,比如cURL中的“用户界面”,它允许您使用一个服务器IP。Php $ch = curl_init(); if($ch) { /* Set username and password */ curl_setopt($ch, CURLOPT_USERNAME, "user"); cur

我想知道,在发送IMAP请求时,是否有办法选择要使用的IP

例如,我有一个具有4个ip地址的服务器,我想将第二个ip地址用于IMAP。我在寻找一些东西,比如cURL中的“用户界面”,它允许您使用一个服务器IP。

Php

$ch = curl_init();

      if($ch) {

        /* Set username and password */ 
        curl_setopt($ch, CURLOPT_USERNAME, "user");
        curl_setopt($ch, CURLOPT_PASSWORD, "secret");

        /* This will fetch message 1 from the user's inbox */ 
        curl_setopt($ch, CURLOPT_URL, "imap://imap.example.com/INBOX/;UID=1");

            $proxy = '127.0.0.1:8888';
            //$proxyauth = 'user:password';

            curl_setopt($ch, CURLOPT_PROXY, $proxy);
            //curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_HEADER, 1);


        /* Perform the fetch */ 
        $res = curl_exec($ch);

        /* Always cleanup */ 
        curl_close($ch);
      }
资源


毫不奇怪,您要寻找的答案是CURLOPT_接口

发件人:


CURLOPT_INTERFACE要使用的传出网络接口的名称。这可以是接口名称、IP地址或主机名。

如果您的服务器有4个IP,但给定的服务仅在其中一个IP上运行,则您应该在DNS中定义一个主机名,该主机名仅指向该地址,例如
imap.example.com
。在应用程序中选择“第二个”充其量是完全不可靠的。你的意思是将客户端套接字绑定到IP,而不是服务器端点吗?谢谢你的回答,我想我的问题还不够清楚。很抱歉。我的imap连接总是使用第一个ip,我希望能够根据需要更改该ip,我不是服务器方面的专家,但仅仅使用PHP不可能做到这一点吗?我找到了这个解决方案,但我不知道如何使用它来获取电子邮件内容或如何“将其标记为已看到”。但是,它可以帮助其他人,所以这里是curl--max time 20--ipv4--接口255.255.255.255--用户代理“Mozilla/4.0(兼容;MSIE 5.01;Windows NT 5.0)”imaps://imap-mail.outlook.com:993/imap/ssl/“--cacert”.\cacert.pem“-u EmailLogin:EmailPassword-ki我很感兴趣。你在哪里找到的?