0
I need to send emails from PHPMailer using proxies IP addresses, I know that to do so, I need to use the fsockopen function so I can conect to the SMTP account, I also know that if I have to connect to the proxy I have to use the fsockopen function again. But using it fsockopen inside another fsockopen is not doable.
I have transparent proxy and require no authentication. I need to send this to a distant SMTP server of an external Email Service Provider.
The code I have tried :
<?php
//SMTP params
$server = 'smtp.espdomain.com';
$server_port = '25';
$username = 'smtp_login';
$password = 'smtp_pass';
//Proxy
$proxy = '1.1.1.1';
$proxy_port = 1111;
//Open connection
$socket = fsockopen($proxy, $proxy_port);
//Send command to proxy
fputs($socket, "CONNECT $server:$server_port HTTP/1.0\r\nHost: $proxy\r\n\r\n");
fgets($socket, 334);
//SMTP authorization
fputs($socket, "AUTH LOGIN\r\n");
fgets($socket, 334);
fputs($socket, base64_encode($username)."\r\n");
fgets($socket, 334);
fputs($socket, base64_encode($password)."\r\n");
$output = fgets($socket, 235);
fputs($socket, "HELO $server \r\n");
$output = fgets($socket, 515);
?>
And it's not work i'm not sure why?
Could socat
commandes help in this situation or is there any solution or alternative solution to do this?
Thank you in advance.
1@Downvoters comments helps, i'm ready to improve my post. – Zakaria Acharki – 2016-03-23T18:29:37.980
1upvoting to balance it, i see nothing wrong with this question – SeanClt – 2016-03-24T23:31:40.807