Anyway I know it's stupid, but I'm trying to find a way to do it. So far I've tried it using a telnet socket and then trying to start up SSL. Then the idea is to send the authentication/SMTP commands. However when trying to connect to say, yahoo's smtp server I'm constantly denied.
Code: Select all
public function openSMTP($host,$user, $password, $port, $debug=0) {
$this->curl_handle = curl_init();
$this->user = $user;
$this->password = $password;
$this->host = $host;
if ($debug == 1) {
$this->dbg = fopen("debug.txt", "w");
curl_setopt($this->curl_handle, CURLOPT_VERBOSE, TRUE);
curl_setopt($this->curl_handle, CURLOPT_STDERR, $this->dbg);
$this->debug = 1;
fwrite($this->dbg,"Opening debug file from openSMTP\n");
}
curl_setopt($this->curl_handle, CURLOPT_URL, "telnet://$host:$port");
curl_setopt($this->curl_handle, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($this->curl_handle, CURLOPT_SSL_VERIFYHOST, TRUE);
curl_setopt($this->curl_handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($this->curl_handle, CURLOPT_PROTOCOLS, CURLPROTO_TELNET);
curl_exec($this->curl_handle);
$error_no = curl_errno($this->curl_handle);
if ($error_no != 0) {
echo 'Problem opening connection. CURL Error: ' . $error_no;
}
}DEBUG INFO:
Opening debug file from openSMTP
* About to connect() to smtp.mail.yahoo.com port 465 (#0)
* Trying 98.139.212.139... * connected
* Connected to smtp.mail.yahoo.com (98.139.212.139) port 465 (#0)
* Recv failure: Connection reset by peer
* Closing connection #0[/text]
Now I know I have the port setting and everything correct because I can openssh into the server and I've managed to send messages via php with a normal SSL/SMTP connection using the PEAR libraries. I'm thinking there must be something wrong with how the SSL is being handled, however connecting without SSL enabled cause the same type refusal.
Does anyone know a better way I could debug this connection or see something I'm doing wrong?