Classic ASP
Classic ASP
Use an Existing Socket SSH Tunnel
See more SMTP Examples
Demonstrates the Chilkat MailMan.UseSshTunnel method, which configures MailMan to use an existing SSH tunnel provided by a Socket object for its SMTP and POP3 connections. This example opens and authenticates a tunnel on a Socket, hands it to MailMan, and then verifies an SMTP login through it.
Background: Sharing one already-established SSH tunnel across objects avoids opening (and authenticating) a separate SSH connection for every component that needs to reach the remote network. Here the tunnel lives on a
Socket object, which MailMan then routes its SMTP/POP3 traffic through. It is the Socket-based sibling of UseSsh, which shares an Ssh object instead.Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' Demonstrates the MailMan.UseSshTunnel method, which configures MailMan to use an existing
' SSH tunnel provided by a Socket object for its SMTP and POP3 connections.
' Open and authenticate the SSH tunnel using a Socket object.
set sshTunnel = Server.CreateObject("Chilkat.Socket")
success = sshTunnel.SshOpenTunnel("ssh.example.com",22)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( sshTunnel.LastErrorText) & "</pre>"
Response.End
End If
success = sshTunnel.SshAuthenticatePw("sshUser","sshPassword")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( sshTunnel.LastErrorText) & "</pre>"
Response.End
End If
set mailman = Server.CreateObject("Chilkat.MailMan")
' Configure the SMTP server connection. These connections will travel through the tunnel.
mailman.SmtpHost = "smtp.example.com"
mailman.SmtpPort = 465
mailman.SmtpSsl = 1
mailman.SmtpUsername = "user@example.com"
mailman.SmtpPassword = "myPassword"
' Tell MailMan to route its connections through the existing tunnel.
success = mailman.UseSshTunnel(sshTunnel)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( mailman.LastErrorText) & "</pre>"
Response.End
End If
' SMTP operations now travel through the shared SSH tunnel.
success = mailman.VerifySmtpLogin()
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( mailman.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "Authenticated with the SMTP server through the SSH tunnel.") & "</pre>"
%>
</body>
</html>