简体   繁体   中英

PHP equivalent of cURL “user-interface” for IMAP

I would like to know, if there is a way to choose what IP to use when sending an IMAP request ?

For example, i have a server with 4 ip adresses and i want to use the 2nd one for IMAP. I look for something, like the "user-interface" in cURL, which allows you to use one of your server IPs.

The answer you were looking for, is, quite unsurprisingly, CURLOPT_INTERFACE.

From documentation :

CURLOPT_INTERFACE The name of the outgoing network interface to use. This can be an interface name, an IP address or a host name.

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

Resources

http://curl.haxx.se/libcurl/c/imap-fetch.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM