Yahoo Answers is shutting down on 4 May 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How to test SMTP port using VBScript?

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.

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.

3 Answers

Relevance
  • 1 decade ago
    Favourite answer

    If you don't mind using command line tools, you can download the PortQry tool from Microsoft:

    http://www.microsoft.com/downloads/details.aspx?fa...

    Details about the software:

    http://support.microsoft.com/kb/832919

    PortQry -n mailServer -e 25

    this will check mailserver on port 25 (SMTP port) and return the intro message.

    Since SMTP requires success codes as the beginning of any response, you can use the find command and look for the proper response:

    PortQry -n mailServer -e 25 | find "220"

    If the find command locates the string "220" (SMTP success code) in the response, find sets ERRORLEVEL to 0 (success). If it doesn't find "220", it sets ERRORLEVEL to 1.

    You can use this return code in your VBS script, or use the batch IF statement, such as:

    IF [NOT] ERRORLEVEL 0 command

    You can probably get the return code and output of PortQry itself in your VBS code too and use it that way if you wish.

  • Anonymous
    4 years ago

    Vbscript Test

  • 1 decade ago

    This isn't vbscript but maybe you can get some ideas from it. I use .NET so while similar they aren't exact.

    http://www.systemnetmail.com/faq/4.2.aspx

    Source(s): Programming and building computers since 1973
Still have questions? Get answers by asking now.