Question:
hello, i am trying to open a ssh tunnel, mailman.SshTunnel(bSmtp, sshHostname, sshPort); mailman.SshAuthenticatePw(bSmtp, ssu, ssp);
and in a loop i want to send emails mailman.SendEmail(email); and in that loop, after i send 10 emails with a smtp server , i want to change the smtp server or to add other smtp creditals and keep sending email through the same tunnel, the problem is that when i change the smtp host or creditals in the loop, the tunnel is dropped.. is that normal? i am not using the mailman.SshCloseTunnel(bSmtp); command inside the loop, and i tried with and without the mailman.CloseSmtpConnection(); after each email or after the 10 emails i send with the same smtp, same result, the tunnel is dropped. i can share the code if someone need it, but it is from the examples, i only added a loop and some conditions to change the smtp host and users after i send 10 emails, if i don't change anything i can send 1000 emails without the tunnel to be dropped.
this is the chilkat log after i send the first email
============================== 1 email ==============================
ChilkatLog:
SendEmail:
DllDate: Feb 15 2010
UnlockPrefix: *********
Username: Administrator
Component: .NET 2.0
Recipients:
NumTo: 1
To: ******@aol.com
NumCC: 0
NumBCC: 0
Need new SMTP connection
SMTP_Connect:
Connecting to SMTP server smtpauth.earthlink.net:587
smtp_host: smtpauth.earthlink.net
smtp_port: 587
smtp_user: ****@earthlink.net
Opening new SSH channel within SSH tunnel.
channelType: direct-tcpip
clientChannel: 100
initialWindowSize: 327680
maxPacketSize: 8192
directTcpHost: smtpauth.earthlink.net
directTcpPort: 587
originatorIP: xxx.xxx.xxx.xxx
originatorPort: 3662
Sent open channel request
ClientChannelNum: 100
ServerChannelNum: 0
ServerInitialWindowSize: 24576
ServerMaxPacketSize: 32768
[SSH] Direct TCP/IP channel successfully opened.
SshChannelNum: 100
InitialResponse: 220-elasmtp-junco.atl.sa.earthlink.net ESMTP Exim 4.67 #1 Mon, 16 Jul 2012
``07:49:45 -0400 2 20-NO UCE. EarthLink does not authorize the use of its computers or network
220 equipment to accept, transmit, or distribute unsolicited e-mail.
sendingHello: EHLO PC
helloResponse: 250-elasmtp-junco.atl.sa.earthlink.net Hello Internet [xx.xx.xx.xx]
250-SIZE 29360128
250-PIPELINING
250-AUTH PLAIN LOGIN CRAM-MD5
250-STARTTLS
250 HELP
login_method: LOGIN
CONNECTED to ESMTP server smtpauth.earthlink.net:587
ConnectionType: SSH Tunnel
subject: 350' Transmission & Engine61
reversePath: ******@cox.net
recipients:
to: ******@aol.com
email_size: 700
Sent DATA terminator
Mail sent to 1 recipient
NumAccepted: 1
NumRejected: 0
===============================10 email ====================================
this is the chilkatlog i get after i send the 10'th email
ChilkatLog:
SendEmail:
DllDate: Feb 15 2010
UnlockPrefix: *********
Username: Administrator
Component: .NET 2.0
Recipients:
NumTo: 1
To: *******@aol.com
NumCC: 0
NumBCC: 0
Sending RSET command..
Using existing/open SMTP connection to send email.
ConnectionType: SSH Tunnel
subject: subject10
reversePath: *******@verizon.net
recipients:
to: ******@aol.com
email_size: 708
Sent DATA terminator
Mail sent to 1 recipient
NumAccepted: 1
NumRejected: 0
Returning success status.
============================== 11 email ================================
and this is the log when i try to send number 11
ChilkatLog:
SendEmail:
DllDate: Feb 15 2010
UnlockPrefix: *********
Username: Administrator
Component: .NET 2.0
Recipients:
NumTo: 1
To: ******@aol.com
NumCC: 0
NumBCC: 0
Need new SMTP connection
SMTP_Connect:
Connecting to SMTP server smtpauth.earthlink.net:587
smtp_host: smtpauth.earthlink.net
smtp_port: 587
smtp_user: **********@earthlink.net
Opening new SSH channel within SSH tunnel.
channelType: direct-tcpip
clientChannel: 101
initialWindowSize: 327680
maxPacketSize: 8192
directTcpHost: smtpauth.earthlink.net
directTcpPort: 587
originatorIP: xxx.xxx.xxx.xxx
originatorPort: 3662
Sent open channel request
SOCKET_ERROR: An existing connection was forcibly closed by the remote host.
numBytesRequested: 16
Failed to receive data on the TCP socket
Failed to read data on SSH connection.
Failed to read packet from SSH server.
Failed to open direct-tcpip channel
failCode: 0
failReason:
Failed to connect to SMTP server.
Failed to connect to SMTP server.
=================================================================
the xxx.xxx.xxx.xxx - is my ip address, and the xx.xx.xx.xx is the ssh server ip
Unfortunately, for now the ability to keep the same SSH tunnel but change the SMTP connection (i.e. open a new SSH channel) is not possible. This will be examined in a future version. (The current version at the time of this writing is v9.3.1)
ok,
thank you for your answer, now, i have another idea, what if instead of using
mailman.SshTunnel
we make a ssh tunnel forwarding the smtp port ex:
to a local port ex: 10000
the smtp will then respond at 127.0.0.1:10000 going through the ssh tunnel,
is it possible to keep this tunnel for more smtp users of the same smtp server?
ex:
i am making this tunnel to outgoing.verizon.net:465 forwarded to local port 10000,
i am sending 10 emails with the user user1@verizon.net and his password pass1, after those 10 emails i
want to send using user2@verizon.net and pass2
i have done a quick test and it seems to work BUT after a while the tunnel crashes or something throwing this:
ChilkatLog:
SendEmail:
DllDate: Feb 15 2010
UnlockPrefix: *******
Username: Administrator
Component: .NET 2.0
Recipients:
NumTo: 1
To: *******@gmail.com
NumCC: 0
NumBCC: 0
Need new SMTP connection
SMTP_Connect:
Connecting to SMTP server 127.0.0.1:10000
smtp_host: 127.0.0.1
smtp_port: 10000
smtp_user: *****@verizon.net
ConnectTimeoutMs: 20000
Timeout waiting to read socket or accept connection
timeoutMs: 30000
InitialResponse:
Failed to get initial SMTP response..
Failed to connect to SMTP server.
=======================================================================
and it never connects again, the timeout is not working, it tries to create a tunnel and send the email through it every second, it's not trying to send for 20 seconds as the ConnectTimeoutMs: 20000 says.. is there a way to reinitialize the Chilkat.SshTunnel sshTunnel = new Chilkat.SshTunnel(); so it is like the first time it loads? i have the
success = sshTunnel.StopAccepting();
and
success = sshTunnel.StopAllTunnels(1000);
set if it fails to send email.
i also have the success = sshTunnel.IsAccepting;
witch is returning true after
success = sshTunnel.BeginAccepting(port);
Thread.Sleep(100);
And one more thing i get,
xml version="1.0" encoding="utf-8" ?
tunnels>
tunnels>
like there are no tunnels..
when i use the
Console.WriteLine(sshTunnel.GetTunnelsXml());
right after i i test if the tunnel is accepting (success = sshTunnel.IsAccepting;)
i get this even when it works