Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MX Query from VFP to validate Email list

Status
Not open for further replies.

psymonj

Programmer
Mar 31, 2005
49
GB
I must first apologise if this thread subject has been raised before, I am not entirely certain what it is I am searching for.

I have been charged with the task of finding a method of querying our list of clients email addresses. The proposed method is to send a 'token' to the respective mail servers to query the existence of the account on that server. If the result is negative, or not returned, then the address will be wiped from our records. This is to act solely as a cleaning method.

I have an inclination that there are controls to do this for me. But I am not au fait with the FVP language and therefore am at a loss as to the validity of these controls.

My questions are basically, is this method possible using VFP 7, 8 or 9? Are there other/better methods, and is this legal?

Many thanks.
Simon
 
About the only way you could do such a query is to send an email to that account a see if you get an invalid response from the server. If you do, then obviously the account isn't valid.
If you don't, the account is most likely good. However, the account would then receive the email, so it needs to be a valid email of some sort.

For info on how to send an email using VFP, go to the FAQ's in this forum, or take a look at the postings and FAQ's in the "Microsoft: VFP - Automation, Mail & 3rd Party Svcs" forum:

-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Here's a page describing how to do the MX lookup in C:
I posted that link on this page: I was hoping that someone else would figure out how to convert to VFP since I haven't had time to yet... it's not very easy because the Windows API doesn't wrap the protocol that is needed, so you'd have to code to TCP/IP sockets directly (you could base this code on the VFP sockets code here )

To my knowledge, no one has done this yet, so you might get famous ;) (that is, if you share the code! I certainly would appreciate it...)

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Many thanks for your replies guys.

I know that the following is written in PHP, but for those 'wizards' here, you may find a way of porting into something for yourself, or magically calling it from VFP. It maybe useless, but as you guys took the trouble to reply to me, I thought I'd at least offer what I've been given/found.

The following was provided from the EchoEcho forum group (thread here
the link for the PHP is:
I hope that this may crack a little light for those of you who know what you are doing ;)

Thanks again.
 
Ah, that's one approach.

That article had two ways of finding the MX record:
1) Wrap the Windows command line program NSLOOKUP
2) Call the PHP function "getmxrr"

#2 is useless in VFP since there's no guarantee that PHP exists on the computer you're on, and, even if it does, it would be hard or impossible to access outside of a PHP web page.

#1, however, is quite possible (though, personally, I don't like relying on commandline program output because of all the overhead):

Code:
FUNCTION GetMXrecord( tcHost )
LOCAL lcOutFile, lcOuput, laOutput[1], lnCnt, lnI
  lcOutFile = addbs(getenv('TEMP'))+'nslookup_out.txt'
  RUN nslookup -type=MX &tcHost > "&lcOutFile"
  lcOutput = filetostr(lcOutFile)
  lnCnt = alines(laOutput, lcOutput)
  for lnI = 1 to lnCnt
    lnPos = AT('mail exchanger = ', laOutput[lnI])

    if left(laOutput[lnI],len(tcHost))=tcHost ;
       and lnPos>0
      return substr(laOutput[lnI],lnPos+17)
    endif
  endfor
  return '' && not found
ENDFUNC

You'll notice a black command window appear as this function executes... there are ways of trying to suppress it, but it is evidence of the command processor (CMD.EXE or COMMAND.COM) executing in order to call NSLOOKUP.EXE and pipe the output into the temp file... whether you hide the window or not this still happens and isn't very quick if you're doing many lookups, and can be blocked by various problems: on locked-down workstations, CMD.EXE and COMMAND.COM may be missing (or inaccessible to the user). The NSLOOKUP.EXE program itself may be missing or inaccessible. The FOXRUN.PIF file may be missing from the distribution. I don't understand the other problems that might happen, but I've always had problems running command line tools like this.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top