Jump to content
Sign in to follow this  

Find MX Record for Easy Emailing

Recommended Posts


I noticed that you had to specify an SMTP server for the function that comes with Autoit (_INetSmtpMail), so I made a quick function to find the Mail Exchange for a given domain. Should work most of the time for finding a valid SMTP server for an email address:


Func GetMX($SomeDomain)
$cmdpid = Run(@comspec & " /C nslookup -querytype=mx " & $SomeDomain, @SystemDir, @SW_HIDE,  2) 
$line = StdoutRead($cmdpid)
$f=StringInStr($line, "mail exchanger =")+16
while $l < $f 
        $l=StringInStr($line, @CR, 0, $i)
return StringMid($line, $f, $l-$f)

I'm use to being able to give InStr a starting point, not an occurance number. Is there a better way?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.