Email validation using MATCH (RegEx)

Hi Kevin,

nice Tool !!!

I´m not sure if my match-string + ‘A’-trick or your match-string is better. Btw I´ve got it elsewere. But mine is catching a lot more mistakes…
[email protected]
[email protected]
aa@[email protected]
[email protected]

unfortunately, all of them pass as OK in yours, so not much is done.

My match-string seems to be perfect and had only the problem with a single letter before the dot like e.g. m.smith@… Possibly there is no other solution than my little ‘A’& - trick?

Did you use the tool to check my match and find false results that are detected on yours?

PS: where do you got the match test tool?

Cheers
Rudolf


  1. -A-Z0-9.!#$%&’’*±/=?^_`{{|}~ ↩︎

You are right it does not catch all of those

image001.png

Don’t know if this is even available still, but it has all sorts of useful tools. I would love a more modern version of this :blush: .

Carl Barnes is active on ClarionHub and newsgroups

image002.png

Kevin Erskine

Ragazzi Enterprise, LLC

415.819.1415

Communication is the key to a successful relationship.

I’ve given up trying to validate formatting (past standard ASCII) and have opted for a DNS lookup of the domain MX record instead, this has allowed me to identify far more that will truly fail than validation alone.
Julian.

1 Like

This is probably the perfect solution, but how long does it take to get a feedback? … and how do you do that :flushed:

Rudolf

Yep, checking for an MX is a pragmatic way to go. When it comes to the someuser@, don’t go there (the temptation to engage in an SMTP dialog with the MX mentioning someuser - very bad idea).

Hello Rudik …

Here is a sample showing how I query an MX record, extract whatever you need to make it your own. It is very quick taking no longer than any other DNS query.

I use a .dll loader class so don’t prototype many procedures but you could use these:

DnsQuery_A(
lpszName LONG,
wType SHORT,
options SHORT,
lpExtra LONG,
lpResults LONG,
lpReserved LONG
),LONG,PASCAL,Name(‘DnsQuery_A’)

DnsRecordListFree(LONG p,LONG t),PASCAL,name(‘DnsRecordListFree’)

Other prototypes …
memcpy(Long lpDestination,Long lpSource,Long dwLen),Long,Proc,Name(’_memcpy’)
strcpy(Long destination,Long Source),Name(’_strcpy’)


jhDNScl_Type.QueryMX Procedure(STRING inDomain)

!-- Defined in the .inc file
!jhDNS:Benign EQUATE(0)
!jhDNS:Invalid EQUATE(1)
!jhDNS:Valid EQUATE(2)

procName EQUATE(‘QueryMX’)

DNS_QUERY_STANDARD EQUATE(0)
DNS_Type_MX EQUATE(0FH)

dwResult LONG,AUTO
dwReturn LONG
lpData LONG ! Pointer to the resulting data … a DNS Record structure

szName CSTRING(128),AUTO

MXRecord GROUP
lpNext LONG
lpszName LONG ! LPCSTR
wType Short
wDataLength Short
dwFlags LONG
dwTtl LONG
dwReserved Long
lpszNameExchange LONG ! LPCSTR
wPreference Short
Pad Short
.

Code
!-- Clear the MXRecord structure initially …
CLEAR(MXRecord)

  !-- Transfer the domain name into a CSTRING ..
  szName = CLIP(Lower(inDomain))
  
  !-- Make the call ..
  dwResult = SELF.myDLL.call('DnsQuery_A',Address(szName),DNS_TYPE_MX,DNS_QUERY_STANDARD,0,Address(lpData),0)
  
  CASE dwResult 
  of 0
     !-- Successful call to DnsQuery_A
     if lpData            
        !-- Copy the MXData pointed to by lpData
        memcpy(Address(MXRecord),lpData,SIZE(MXRecord))
        
        !-- lpszNameExchange points to an Mail Exchange Server ..
        strcpy(Address(szName),MXRecord.lpszNameExchange)
        
        !-- Free the internal memory allocated by DnsQuery_A ..
        dwResult = SELF.myDLL.call('DnsRecordListFree',lpData,1)

        !-- and set dwSuccess = True
        dwReturn = jhDNS:Valid
           
     ELSE
        !-- set dwSuccess indicating not found
        dwReturn = jhDNS:Invalid
     .
  
  of 9003
     !-- Name does not exist
     dwReturn = jhDNS:Invalid
     
  ELSE

! MESSAGE('DNS MX Query: ’ & inDomain & |
! '||Query dwResult = ’ & dwResult )

     !-- Some other unknown ..
     dwReturn = jhDNS:Benign
  .
  
  RETURN(dwReturn)

I agree with Simon’s comment not to enter into SMTP engagement outside the actual send attempt and this method doesn’t tell you whether an actual email address exists nor does it indicate whether the catchall is active.

I periodically query all target domains saving the query date & result: pass/fail that way I can eliminate emails that I know in advance are going to bounce.

Julian

1 Like