English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I need to test several servers to verify that the SMTP service is accepting connections on port 25. I prefer to do this using a VBScript. I would also prefer to do this without the need for commercial software. I am well versed in VBScript and not easily stumped, however I am at wits end. Any help is appreciated.

2007-12-28 09:45:03 · 2 answers · asked by davidmi711 7 in Computers & Internet Programming & Design

Since this script is for work and licensing compliance is VERY important here, hacking the MS Winsock control included with VS is not a viable option. Any other ideas would be great.

2007-12-31 02:22:25 · update #1

2 answers

If Visual Studio is installed on the box where you'll be running the script you can use the following:

Option Explicit

Const sckClosed= 0
Const sckOpen= 1
Const sckListening= 2
Const sckConnectionPending= 3
Const sckResolvingHost= 4
Const sckHostResolved= 5
Const sckConnecting= 6
Const sckConnected= 7
Const sckClosing= 8
Const sckError= 9

Dim sock, started

Set sock = CreateObject("MSWinsock.Winsock")
sock.Connect "mailserver", 25

started = Now()
Do While sock.State <> sckConnected And sock.State <> sckError
If DateAdd("s", 10, started) < Now() Then
Exit Do
End If

WScript.Sleep 100
Loop

Select Case sock.State
Case sckConnected
MsgBox "Connected"
Case sckError
MsgBox "Can't connect"
Case Else
MsgBox "Unexpected state - " & sock.State
End Select

sock.Close


If Visual Studio is not present, the script will fail when it tries to do CreateObject("MSWinsock.Winsock"). If this is the case, you can download the OCX available at http://www.gurgensvbstuff.com/index.php?ID=27 and modify the code as they suggest.

2007-12-28 11:06:49 · answer #1 · answered by Sean D 2 · 0 0

Just pay a professional man.
They are broke.
Or uh... hmm.
Yeah just pick the guy above me thats smarter.

2007-12-31 03:46:55 · answer #2 · answered by sierrasurfer3 2 · 0 3

fedest.com, questions and answers