How to check the valid email (able to send)

How to check the valid email (able to send)

Postby dutch » Fri Nov 27, 2009 3:43 pm

Dear All,

I love to check the email is valid (able to send pass), not only correct grammar but can send successful too.

Regards,
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How to check the valid email (able to send)

Postby Otto » Fri Nov 27, 2009 3:52 pm

Hello Dutch,

this is how I test to validate the entry of emails.

Best regards,
Otto

Code: Select all  Expand view


******************************************************************************
** FUNCTION Validate_Email_Address(cE_Mail) to Validate the entry of e.mail **
**          address - By RAMESH BABU P (aksharasoft@hotmail.com)            **
******************************************************************************
* and some changes I made

FUNCTION Validate_Email_Address(cE_Mail)
   LOCAL lOk := .T., cValid_Letters := "abcdefghijklmnopqrstuvwxyz0123456789._-@"
   LOCAL n
   local cToken       := ""
   local cDomainPart  := ""
   local cLocalPart   := ""
   local nLocalPart   := 0
   local nAnzPunkte   := 0
   local I            := 0

cE_Mail := ALLTRIM(cE_Mail)

IF EMPTY(cE_Mail)
   RETURN .T.
ENDIF

DO CASE

   * Check for existance of '@' and '.' the basic characters of an email
   CASE (.NOT. "@" $ cE_Mail) .OR. (.NOT. "." $ cE_Mail)

        lOk := .F.

   * Check '@' is typed more than the required 1 time
   CASE NumAt( "@",cE_Mail ) > 1
  // FT_NOOCCUR("@",cE_Mail,.F.) >1
        lOk := .F.

   * Check wether any characters are between '@' and '.' or type continuous
   CASE ( RAT(".", cE_Mail) - AT("@", cE_Mail) <= 2 )

        lOk := .F.

OTHERWISE

//local-part - there must be a local part
cToken := StrToken( cE_Mail,1,'@' )
nLocalPart := len( ALLTRIM(cToken) )
if nLocalPart = 0 .or. nLocalPart > 64
   lOk := .F.
endif

//domain-part
 cDomainpart  := StrToken( cE_Mail,2,'@' )
* Check domain-part if  '.' is typed more than the required 1 time

 nAnzPunkte := NumAt( ".",cDomainpart )
 FOR I := 1 to nAnzPunkte + 1
   cToken   := StrToken( cDomainpart,I,'.' )

   if I = nAnzPunkte
      if len(ALLTRIM(cToken)) < 2
         lOk := .F.
      endif
   else
      if len(ALLTRIM(cToken)) < 1
         lOk := .F.
      endif
   endif

next


   FOR n = 1 TO LEN(cE_Mail)
      IF .NOT. LOWER( SUBSTR(cE_Mail,n,1) ) $ cValid_Letters
         lOk := .F.
         EXIT
      ENDIF
   NEXT

ENDCASE

IF .NOT. lOk
   if MsgYesNo("Keine gültige Emailadresse - "+ CRLF +   ;
         "Email trotzdem speichern?")=.t.
         lOk:=.t.
         endif
ENDIF

RETURN lOk
//----------------------------------------------------------------------------//

 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: How to check the valid email (able to send)

Postby dutch » Fri Nov 27, 2009 6:32 pm

Dear Otto,

This function is checking the email grammar like xxxxx@hotmail.com. Does it return True? If so, it does not check the Sendable Email. I need to check, is this existing email account?

Regards,
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 22 guests