PHP equivalent of cURL "user interface" for IMAP

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

For example, I have a server with 4 ip addresses, and I want to use the second for IMAP. I am looking for something, such as a "user interface" in cURL, which allows you to use one of the IP addresses of your server.

+4
source share
1 answer

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 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

0
source

All Articles