PHP Classes

Does class support ssl via socks?

Recommend this page to a friend!

      SMTP E-mail sending class  >  All threads  >  Does class support ssl via socks?  >  (Un) Subscribe thread alerts  
Subject:Does class support ssl via socks?
Summary:socks works only when ssl=0 or tls=1
Messages:4
Author:Alex
Date:2012-08-28 17:32:48
Update:2012-08-28 20:56:19
 

  1. Does class support ssl via socks?   Reply   Report abuse  
Picture of Alex Alex - 2012-08-28 17:32:48
SSL = 1

Resolving SMTP server domain "smtp.gmail.com"...
Could not send the message to example@gmail.com.
Error: could not connect to the host "smtp.gmail.com":

SSL = 0 // Error is ok, because gmail doesn't work without ssl

Resolving SMTP server domain "smtp.gmail.com"...
Connected to the SOCKS server 192.168.1.1
Negotiating the authentication method ...
Connecting to SMTP server IP 173.194.71.108 port 465...
Connected to SMTP server "smtp.gmail.com".
Could not send the message to example@gmail.com.
Error: it was not possible to read line from the SMTP server: data access time out

SSL = 0 AND start_tls=1 works fine with gmail via socks

Best Regards, Alex

P.S. Dear Manuel Lemos, Thank you very much for your brilliant email classes.

  2. Re: Does class support ssl via socks?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2012-08-28 20:56:19 - In reply to message 1 from Alex
Yes, for now secure connections can only be established with SSL directly or via socks using start TLS because that is the way to start a secure connection on the top of a non-secure connection with the socks server.

  3. Re: Does class support ssl via socks?   Reply   Report abuse  
Picture of Amir Amir - 2016-08-22 18:46:07 - In reply to message 2 from Manuel Lemos
In my host class smtp.php doesn't work trough proxySOCKS5, why?

This is what shows:
Resolving SMTP server domain "smtp.mail.ru"...
Connecting to SOCKS server "$proxyIP" '$proxyPort' ... // Here $proxyIP and $proxyPort means my proxyserver and port
Connected to the SOCKS server "$proxyIP" // Here $proxyIP means my proxyserver
Negotiating the authentication method ...
Connecting to SMTP server IP 94.100.180.160 port 465...
Could not send the message to air-aktau@mail.ru. Error: SOCKS error: Connection refused

Does it mean that I connected to my proxyserver or not?
If I connected to my proxyserver, why it could not send the message and shows SOCKS error and Connection refused?
Do I need to download all your files (smtp.php, test_smtp.php, getmxrr.php, test_smtp_prepare_data.php) and all sasl's files to my host ?
Could you give me, please instructions step by step what I have to do and change in all your files (smtp.php, test_smtp.php, getmxrr.php, test_smtp_prepare_data.php)!
You can alsow email me to 666amir777@mail.ru, thank you Mr.Manuel Lemos!!!

What could be wrong in code?
<?php
require("smtp.php");
require("sasl.php");

$from="user@mail.ru"; /* Change this to your address like "me@mydomain.com"; */ $sender_line=__LINE__;
$to="recipient@mail.ru"; /* Change this to your test recipient address */ $recipient_line=__LINE__;

if(strlen($from)==0)
die("Please set the messages sender address in line ".$sender_line." of the script ".basename(__FILE__)."\n");
if(strlen($to)==0)
die("Please set the messages recipient address in line ".$recipient_line." of the script ".basename(__FILE__)."\n");

$smtp=new smtp_class;

$smtp->host_name="smtp.mail.ru"; /* Change this variable to the address of the SMTP server to relay, like "smtp.myisp.com" */
$smtp->host_port=465; /* Change this variable to the port of the SMTP server to use, like 465 */
$smtp->ssl=0; /* Change this variable if the SMTP server requires an secure connection using SSL */

//$smtp->http_proxy_host_name=''; /* Change this variable if you need to connect to SMTP server via an HTTP proxy */
//$smtp->http_proxy_host_port=''; /* Change this variable if you need to connect to SMTP server via an HTTP proxy */

$smtp->socks_host_name = 'myproxyserverip'; /* Change this variable if you need to connect to SMTP server via an SOCKS server */
$smtp->socks_host_port = '30000'; /* Change this variable if you need to connect to SMTP server via an SOCKS server */
$smtp->socks_version = '5'; /* Change this variable if you need to connect to SMTP server via an SOCKS server */

$smtp->start_tls=1; /* Change this variable if the SMTP server requires security by starting TLS during the connection */
$smtp->localhost="localhost"; /* Your computer address */
$smtp->direct_delivery=0; /* Set to 1 to deliver directly to the recepient SMTP server */
$smtp->timeout=10; /* Set to the number of seconds wait for a successful connection to the SMTP server */
$smtp->data_timeout=0; /* Set to the number seconds wait for sending or retrieving data from the SMTP server.
Set to 0 to use the same defined in the timeout variable */
$smtp->debug=1; /* Set to 1 to output the communication with the SMTP server */
$smtp->html_debug=1; /* Set to 1 to format the debug output as HTML */
$smtp->pop3_auth_host=""; /* Set to the POP3 authentication host if your SMTP server requires prior POP3 authentication */
$smtp->user="user@mail.ru"; /* Set to the user name if the server requires authetication */
$smtp->realm=""; /* Set to the authetication realm, usually the authentication user e-mail domain */
$smtp->password="secret"; /* Set to the authetication password */
$smtp->workstation=""; /* Workstation name for NTLM authentication */
$smtp->authentication_mechanism="LOGIN";
if($smtp->direct_delivery)
{
if(!function_exists("GetMXRR"))
{
/*
* If possible specify in this array the address of at least on local
* DNS that may be queried from your network.
*/
$_NAMESERVERS=array();
include("getmxrr.php");
}
/*
* If GetMXRR function is available but it is not functional, to use
* the direct delivery mode, you may use a replacement function.
*/
/*
else
{
$_NAMESERVERS=array();
if(count($_NAMESERVERS)==0)
Unset($_NAMESERVERS);
include("rrcompat.php");
$smtp->getmxrr="_getmxrr";
}
*/
}

if($smtp->SendMessage(
$from,
array(
$to
),
array(
"From: $from",
"To: $to",
"Subject: Testing Manuel Lemos' SMTP class",
"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")
),
"Hello $to,\n\nIt is just to let you know that your SMTP class is working just fine.\n\n.\n"))
echo "Message sent to $to OK.\n";
else
echo "Could not send the message to $to.\nError: ".$smtp->error."\n";
?>

  4. Re: Does class support ssl via socks?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-08-22 20:18:20 - In reply to message 3 from Amir
It seems it connects to the socks server but then the socks server fails to connect to the remote server. I suspect that is because the connection must be in SSL. Try setting the SSL variable to 1.

PS. for new topics do not reply to old ones. Just post a new topic using the "Post a new forum message" link:

phpclasses.org/post_forum_message.h ...