Page 1 of 2 12>
Topic Options
#131292 - 2004-12-15 02:32 AM MX Record lookup help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Does anyone know of a FREE tool or method to perform an MX record lookup from within KiXtart to supply an address to an application?

Microsoft's NSLOOKUP allows you to set a filter to do this, but not in a non-interactive mode.
How to obtain Internet Mail Exchanger records with the Nslookup.exe Utility
http://support.microsoft.com/default.aspx?scid=kb;EN-US;203204

Example:
NSLOOKUP
[now puts you into an interactive mode]
set q=mx [now only queries mx records]
mymailserver.mycompany.com

Would come back with something similar to this:
Server: mydnsserver.mycompany.com
Address: 122.120.100.1

authoritative answer:
mymailserver.mycompany.com MX preference = 10, mail exchanger = server1.eastcoast.mycompany.com
mymailserver.mycompany.com MX preference = 0, mail exchanger = server1.westcoast.mycompany.com
mymailserver.mycompany.com MX preference = 0, mail exchanger = server2.westcoast.mycompany.com



What I'm attempting to do is use BLAT to send e-mail, but I want to have KiXtart check and verify first that the server is up and if not then check the next server in line
BLAT does not appear to natively support an MX record lookup so I want to attempt to have KiX support it for BLAT.

I've found tools to do it, but would prefer a free method or tool to do so. In my case I already know all the real names, so I could manually code it in KiXtart, but I would rather automate it so that in case a server is changed I don't have to modify my code, which is the purpose of having an MX record in the first place.


Email Toolbox MX Record
http://www.arclab.com/products/emailtoolbox/mxrecord.html

HexValidEmail
http://www.hexillion.com/hg/asp-email-verification-component/

I'm sure Howard could supply an EXE using Perl to do this. Too bad Microsoft does not allow this in a non-interactive mode


Edited by NTDOC (2004-12-15 02:39 AM)

Top
#131293 - 2004-12-15 04:03 AM Re: MX Record lookup help
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Maybe I'm misunderstanding the problem but nslookup does have a noninteractive mode... so wouldn't what you want be:

nslookup -q=mx mymailserver.mycompany.com

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/nslookup.mspx

Top
#131294 - 2004-12-15 05:56 AM Re: MX Record lookup help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Thanks Al - consider your DOUBLE CTRL-ALT-DEL paid off

I thought I had tried that already, but was on someone else's VMware session and it did not appear to work.

I just tried it at home and it seems to work. Will try it again at work tomorrow on my own system.

Cheers

Top
#131295 - 2004-12-15 08:47 AM Re: MX Record lookup help
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
dunno what MX record has to do with server being on or off...
_________________________
!

download KiXnet

Top
#131296 - 2004-12-15 09:38 PM Re: MX Record lookup help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
An application that supports it (Exchange Server) will query the MX records and test that the remote system is responding, if so it will send the e-mail. If not responding it will check the next available server in the list and so on until it either finds a server responding or not.

As an example, these servers all handle e-mail for you.

10 smtp.Gwspikval.Com
30 smtp.inet.fi
20 smtp.tele.fi

1st try goes to smtp.Gwspikval.Com
2nd try goes to smtp.tele.fi
3rd try goes to smtp.inet.fi


Edited by Jooel (2004-12-15 10:23 PM)

Top
#131297 - 2004-12-15 09:39 PM Re: MX Record lookup help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Al,

Yes it does work. Thanks. Now I'll have to write up some code to emulate the checking of the remote systems based upon the returned data.

Top
#131298 - 2004-12-16 07:30 AM Re: MX Record lookup help
terron Offline
Fresh Scripter

Registered: 2004-12-08
Posts: 11
Loc: Tyler, TX
i always wondered how you could 'set type=mx' from a prompt. Al Po, you're my internet hero :>
Top
#131299 - 2004-12-16 08:16 AM Re: MX Record lookup help
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Quote:

you're my internet hero




aw shucks


Top
#131300 - 2004-12-16 10:29 AM Re: MX Record lookup help
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You can also use redirection.

For simple queries:
Code:
echo ls sgb.co.uk | nslookup



For multi-line queries, write the lines to a file and redirect it in:
Code:
nslookup < ns_lookup_commands.txt


Top
#131301 - 2004-12-16 10:44 AM Re: MX Record lookup help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
You have any tips for the Telnet portion Richard?

So far in my testing the errorcode level is the same if it can or can not connect to the remote server. So for now I'm using PING for the connection test, but want/need to use telnet for the test. Not sure how to complete a connection and send it a quit command and then check the errorlevel code.

Top
#131302 - 2004-12-16 11:28 AM Re: MX Record lookup help
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
The most obvious answer would be to use WScript.Shell and the .Exec method to start a telnet process.

Use the StdIn property to send commands, and StdOut to get results.

If I get a chance I'll write a wrapper for this, as it could be quite useful for general "send/expect" tasks. It'll be a little while though as I'm just back from a business trip to Prague and will need to catch up on paperwork.

Top
#131303 - 2004-12-16 01:21 PM Re: MX Record lookup help
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Or http://home.comcast.net/~habullock/habobjects.htm
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#131304 - 2004-12-16 02:55 PM Re: MX Record lookup help
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
well... kixform's is working on gettings its socket support working....
Top
#131305 - 2004-12-16 10:02 PM Re: MX Record lookup help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Richard
hmmm... Well then I see this as a reason to request functionality to an upcoming new version of KiXtart.

Howard
Thanks for the idea of your HABobjects.DLL but for what I really wanted it for it really has to be something that is either native to KiXtart or native to 2000/XP.

I guess for now I'll just manually input my mail server address and wait for KiXtart to support such a feature, or perhaps look further into WSH as Richard suggests.

Top
#131306 - 2004-12-17 02:23 AM Re: MX Record lookup help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Well not pretty and not a best practice but it works.

Al_Po wrote this little tid-bit up and we cleaned it up a little for presentation until such time as there is a better method.

Code:
If MailServerUp($Server)

? 'System is responding'
Else
? 'System did not respond'
EndIf

Function MailServerUp($mailserver)
Dim $output,$,$fh,$line,$path
$output='%temp%\output.txt'
If Exist($output)
Del $output
EndIf
Run '%comspec% /c telnet -f ' + $output + ' ' + $mailserver + ' 25'
Sleep 2
$=EndProc('telnet.exe')
Sleep 1
$fh=FreeFileHandle()
If Open($fh,$output)=0
$line=ReadLine($fh)
While @ERROR=0
If Left($line,3)=220
$MailServerUp=1
EndIf
$line=ReadLine($fh)
Loop
$=Close($fh)
EndIf
If Exist($output)
Del $output
EndIf
EndFunction

Function EndProc($proc, optional $strComputer)
DIM $Process
If $strComputer=''
$strComputer='.'
EndIf
For Each $Process In GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer +
"\root\cimv2").ExecQuery("Select * from Win32_Process where Name= " +'"'+$Proc+'"')
$Process=$Process.Terminate
Next
EndFunction


Top
#131307 - 2004-12-17 05:27 AM Re: MX Record lookup help
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
All I can say is, I warned DOC it wasn't going to be pretty.
Top
#131308 - 2004-12-17 01:03 PM Re: MX Record lookup help
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
doc...
thinking about that telnet shit...

you could use sendmail() udf.
only problem is, it will flash on your screen but at least it requires no installation
_________________________
!

download KiXnet

Top
#131309 - 2004-12-17 07:02 PM Re: MX Record lookup help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
I'm actually using BLAT for sending the e-mail. I was just wanting the application to send the e-mail correctly like a full fledged mail application does. The application checks to make sure there is a response from the SMTP server, if not it then checks the next and so on.

For my production script I won't bother, I'll plug in the actual name of the main SMTP mail server. I just thought it was an interesting [thinking outside the box] method of how Al accomplished the check.

I'll clean up the script and post an example. Hopefully maybe Ruud will consider some type of socket support so that we could perform this and other types of TCPIP tasks.

Top
#131310 - 2004-12-17 07:10 PM Re: MX Record lookup help
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, no client will do MX checks, that's for sure.
blat is kinda not a email client as it goes directly to smtp layer.
and one using a tool that goes there, should at least have minor understanding what that means.
really.
_________________________
!

download KiXnet

Top
#131311 - 2004-12-17 11:19 PM Re: MX Record lookup help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
You're correct in that, most PC clients don't, but they should.

Here is a brief discussion on this subjec from 2002

Redundant Mail Relays with Pine, Eudora and Outlook
http://www.nber.org/redundant.html


If you're really bored and want to do more reading here are further links of information on the subject.

Windows applications appear to be the ones that don't follow the rules as there intended for this subject.

Delivering mail to user AT domain.com
http://www.han.com/dns.html

Simple Mail Transfer Protocol (SMTP)
http://www.auggy.mlnet.com/ibm/3376c46.html#smtpdom

MX, Mail Exchange Records
http://www.domainavenue.com/mx.htm

How do I configure and test the MX Record for my Internet Domain name?
http://www.petri.co.il/configure_mx_records_for_incoming_smtp_email_traffic.htm

Top
Page 1 of 2 12>


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 700 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.064 seconds in which 0.021 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org