Computing.Net > Forums > Programming > Resolve MX-record from DNS into var

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Resolve MX-record from DNS into var

Reply to Message Icon

Name: ikerstges
Date: March 23, 2004 at 05:33:33 Pacific
OS: Windows2000-DOS
CPU/Ram: PIII/1024
Comment:

Hi,
I'm using blat (http://www.blat.net/) to send emails from batch-scripts. (w2k command environment) I always used sent my emails directly to the smpt-server name, but that will not work anymore. Instead I need to request the smtp servername from dns by reading the MX-record.

For this, I can type
nslookup -querytype=mx [domainname] <enter>

The results look similar to:
scct.emea.company.com MX preference = 20, mail exchanger = cli-location-195.scct.emea.company.com
scct.emea.company.com MX preference = 10, mail exchanger = cli-location-194.scct.emea.company.com
scct.emea.company.com nameserver = kate.company.com

I need to store into a variable the results:
a) cli-location-195.scct.emea.company.com
b) cli-location-194.scct.emea.company.com

I have tried to use the "="sign as delimiter with following commandline:
FOR /F "tokens=1,2,3 delims==" %a in ('nslookup -type=mx scct.emea.fedex.com') do set SMTPSERVER=%c

But this results in error: Non-existent domain (probably the nslookup command needs DNS input from reverse-lookup but i guess this is not possible in my 'FOR' statement above).

Does someone have any suggestions how to achieve this?


Thanks in advance!
Igor.




Response Number 1
Name: ikerstges
Date: March 23, 2004 at 06:06:01 Pacific
+1
Reply:

To be clear.... I'm interested in:

a) Having a scripting solution (for commandline tools like Blat)
-AND-
b) Having a VB6 solution (VB-control) to allow built-in sendmail functionality within my VB application.

Any help will be greatly appreciated!

Kind regards,
Igor.


Reply to Message Icon

Related Posts

See More


Batch file that can do ma... Sieve of Eratosthenes C p...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Google Ads



Results for: Resolve MX-record from DNS into var

Get MX record via C program. www.computing.net/answers/programming/get-mx-record-via-c-program/4898.html

get date into vars; layout independ www.computing.net/answers/programming/get-date-into-vars-layout-independ/14133.html

Extracting variable from txt file? www.computing.net/answers/programming/extracting-variable-from-txt-file/10986.html