我想知道,如果有办法选择在发送IMAP请求时使用哪种IP?
例如,我有一个带有4个IP地址的服务器,我想将第二个用于IMAP。我寻找的东西,比如"用户界面"在cURL中,它允许您使用您的一个服务器IP。
答案 0 :(得分:1)
毫无疑问,您正在寻找的答案是CURLOPT_INTERFACE。
CURLOPT_INTERFACE 要使用的传出网络接口的名称。这可以是接口名称,IP地址或主机名。
答案 1 :(得分:0)
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);
}
<强>资源强>