Visual FoxPro
Visual FoxPro
Use an Existing Ssh Object as the Tunnel
See more POP3 Examples
Demonstrates the Chilkat MailMan.UseSsh method, which configures MailMan to use an existing SSH tunnel provided by an Ssh object for its SMTP and POP3 connections. This example connects and authenticates an Ssh object separately, hands it to MailMan, and then performs a POP3 operation through it.
Background: Rather than having MailMan open its own tunnel (
SshOpenTunnel), you can manage the SSH connection yourself and share it. That is valuable when several Chilkat objects must reach the same remote network — they all ride one authenticated SSH connection instead of each opening its own — and it enables advanced setups such as multi-hop SSH, where the Ssh object is already chained through intermediate servers.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loSsh
LOCAL loMailman
LOCAL lnCount
lnSuccess = 0
* Demonstrates the MailMan.UseSsh method, which configures MailMan to use an existing SSH
* tunnel provided by an Ssh object for its SMTP and POP3 connections.
* Establish the SSH connection separately, using an Ssh object.
loSsh = CreateObject('Chilkat.Ssh')
lnSuccess = loSsh.Connect("ssh.example.com",22)
IF (lnSuccess = 0) THEN
? loSsh.LastErrorText
RELEASE loSsh
CANCEL
ENDIF
lnSuccess = loSsh.AuthenticatePw("sshUser","sshPassword")
IF (lnSuccess = 0) THEN
? loSsh.LastErrorText
RELEASE loSsh
CANCEL
ENDIF
loMailman = CreateObject('Chilkat.MailMan')
* Configure the POP3 server connection. These connections will travel through the tunnel.
loMailman.MailHost = "pop.example.com"
loMailman.MailPort = 995
loMailman.PopSsl = 1
loMailman.PopUsername = "user@example.com"
loMailman.PopPassword = "myPassword"
* Tell MailMan to route its connections through the already-connected Ssh object.
lnSuccess = loMailman.UseSsh(loSsh)
IF (lnSuccess = 0) THEN
? loMailman.LastErrorText
RELEASE loSsh
RELEASE loMailman
CANCEL
ENDIF
* POP3 operations now travel through the shared SSH connection.
lnCount = loMailman.GetMailboxCount()
IF (lnCount < 0) THEN
? "Failed to get the mailbox count."
ELSE
? "Mailbox count: " + STR(lnCount)
ENDIF
loSsh.Disconnect()
RELEASE loSsh
RELEASE loMailman