Valid email address

User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Valid email address

Post by Otto »

Does someone have a function to check if a email address is valid.
Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Valid email address

Post by ukoenig »

Hello Otto,

I don't know, what You mean with valid. There are two tests possible :
Syntax-check ( text-input ) or If a Connection is possible.
If You want to collect E-Mail-addresses with possible connections, there is a freeware-solution for it.
If You need a solution for Syntax-check ( not easy ), I can give You some interesting links to German-forums.
Image
Program Description:
Mail List Validator verifies every e-mail address from a given mailing list, allows to determine about
90 % of dead e-mail addresses.

Another Solution : Fast Email Verifier ( not free of charge )
---------------------------------------------------------------------
FEV has the following features:
The fastest verifying of bad email addresses and invalid domains.
Easy ability to import email lists from CSV and TXT files.
Easy ability to import email addresses from external sources through ODBC SQL
Easy ability to export email addresses through ODBC SQL
Easy ability to export email addresses to Paradox, DBase, Excel, Text (.CSV), Word, SYLK, Lotus 1-2-3, QuattroPro, SQL script, XML, MS Access database files
Easy ability to import email addresses from Windows Address Book (.WAB)
Easy ability to synchronize verification results with Windows Address Book
Creates a detailed log for every operation.
Fast multi-threaded engines. The speed depends generally on the user's connection and Internet traffic.
Support of different mailing list formats.
Image

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Valid email address

Post by RAMESHBABU »

Mr.Otto/Mr.Uwe,

>>If You need a solution for Syntax-check ( not easy ),

My following code is working Ok with me. You can try it if you need Syntax-check for e-mail address:

Code: Select all

******************************************************************************
** FUNCTION Validate_Email_Address(cE_Mail) to Validate the entry of e.mail **
**                                          address                         **
******************************************************************************

FUNCTION Validate_Email_Address(cE_Mail)

LOCAL lOk := .T., cValid_Letters := "abcdefghijklmnopqrstuvwxyz"+;
                                    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"+;
                                    "0123456789._-@"
LOCAL n

cE_Mail := ALLTRIM(cE_Mail)

* If you want empty email
IF EMPTY(cE_Mail)
   RETURN .T.
ENDIF

DO CASE

   * Check for minimum length of the email address i.e. 8
   CASE LEN(ALLTRIM(cE_Mail)) < 8

        lOk := .F.

   * 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 (Nonforum toolkit function)
   CASE 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

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

ENDCASE

IF .NOT. lOk
    Alert("The E.Mail address you have entered does not seem to be valid;"+    ;
         "E.Mail address. Please Check.")
ENDIF

RETURN lOk
 
Regards,

- Ramesh Babu P
Last edited by RAMESHBABU on Sun Apr 12, 2009 1:26 am, edited 2 times in total.
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Valid email address

Post by Otto »

Hello Ramesh Babu , hello Uwe,

Thank you for your help.

Your FUNCTION Validate_Email_Address will be soon included in my all.prg file.
Are these your own functions:
FT_NOOCCUR
YESNO

Uwe you had previous a link in your post with a newsgroup discussion
(GERMAN) about valid emails. I can’t find the link anymore.

I think I read – and I write sometimes emails to addresses with upper case in it – that upper case is also allowed.
Is this true?
And I also read that a valid email at least is 7 characters long.

Thank you for your help.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Valid email address

Post by ukoenig »

Hello Otto,

Here are the links to the sites for syntax-check.
I didn't know, if it could be useful for You.
There have been discussions about these problems, how to check in different ways.
Maybe there are still informations, You can need.

Informations :
A very good specification ( it is a lot, You have to allowing for ) :
http://aktuell.de.selfhtml.org/artikel/ ... ail-check/
some more :
http://www.phpugffm.de/pipermail/ugffm/ ... 02429.html
http://www.flashforum.de/forum/archive/ ... -8306.html
http://www.ayom.com/faq/wie-validiert-m ... a-252.html
http://www.delphipraxis.net/topic7231.html
Some software ( maybe useful ) :
http://wareseeker.com/free-email-syntax-checker/

Regards
Uwe :lol:
Last edited by ukoenig on Sat Apr 11, 2009 12:34 pm, edited 8 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
IBTC
Posts: 103
Joined: Sat Oct 18, 2008 8:13 pm
Location: Stuttgart, Germany
Contact:

Re: Valid email address

Post by IBTC »

Otto wrote: Are these your own functions:
FT_NOOCCUR
This function is from Nanforum Toolkit: http://www.somers.com.br/cgi-bin/w3ng.c ... .ng+111289
Best Regards,
Ruediger Alich

---
HMG 3.1.3 | FTDN/FWH 13.12 | Harbour 3.2 | BCC/MinGW | Windows XP/Vista/7/8/10 (32/64-Bit), Wine (Linux/Mac) - started 1999 with FW, 1989 with Clipper
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Valid email address

Post by nageswaragunupudi »

function NumAt( <cSearchfor>, <cString> ) --> nOccurances
in ct.lib ( available in harbour and xharbour )
can be used instead of FT_NOOCCUR
Regards

G. N. Rao.
Hyderabad, India
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Valid email address

Post by RAMESHBABU »

Hello Mr.Otto,

>Your FUNCTION Validate_Email_Address will be soon included in my all.prg file.
You are most welcome.

>Are these your own functions:
As Mr.Ruediger Alich said, FT_NOOCCUR is Nonforum toolkit function. And YesNo is my function.

Regards,

- Ramesh Babu P
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Valid email address

Post by Otto »

Hello Ramesh Babu,

I think we have to include Upper case and minus.
But I didn't found a definitive description what all is allowed, yet.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Badara Thiam
Posts: 160
Joined: Tue Oct 18, 2005 10:21 am
Location: France
Contact:

Re: Valid email address

Post by Badara Thiam »

Mr Otto,

We can use upper or lower caracters in a email adress.
Like we want. This is not the same for domain name adress,
where upper and lower are differents.

Best Regards.
Badara Thiam
http://www.icim.fr
User avatar
RAMESHBABU
Posts: 591
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Valid email address

Post by RAMESHBABU »

Mr.Otto,

I have edited my function above adding UPPER case letters and - (MINUS). And also validated
the length of the email. Please check.

Regards,

- Ramesh Babu P
User avatar
sygecom
Posts: 42
Joined: Tue Mar 11, 2008 3:18 am
Location: Brasil

Re: Valid email address

Post by sygecom »

Hello,
Here's an example:

Code: Select all

****************************
Function Valid_Email(cmail)
****************************
Local oRegEx, bVal
TRY
   oRegEx := Createobject("VBScript.RegExp")
CATCH error
   RETURN .T.
END
oRegEx:Pattern :="^[\w-\.]{1,}\@([\da-zA-Z-_]{1,}\.){1,}[\da-zA-Z-_]{2,3}$"
cmail := ALLTRIM(cmail)
bVal := oRegEx:Test(cMail)
Release oRegEx
Return bVal
 
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Valid email address

Post by nageswaragunupudi »

The above function returns Valid for the following email address. Can this be right ?

Code: Select all

Valid_Email( "..T.@TOM.COM.COM.COM.COM " ) --> returns .T.                                                                           
 
This address " .@a.com" passes Valid_Email but RameshBabu's function returns invalid
Regards

G. N. Rao.
Hyderabad, India
hua
Posts: 861
Joined: Fri Oct 28, 2005 2:27 am

Re: Valid email address

Post by hua »

IBTC wrote: This function is from Nanforum Toolkit: http://www.somers.com.br/cgi-bin/w3ng.c ... .ng+111289
Under xHarbour, Nanforum stuffs are in libnf.lib. Under Harbour it's hbnf.lib
FWH 11.08/FWH 19.03
xHarbour 1.2.1 (Rev 6406) + BCC
Harbour 3.1 (Rev 17062) + BCC
Harbour 3.2.0dev (r1904111533) + BCC
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Valid email address

Post by Otto »

Hello,

when I posted my question I thought this is an easy task and not valid a question on the forum.
But going into details it seems not that easy.

http://en.wikipedia.org/wiki/E-mail_address

Now I know that an email is divided by an @ and that you have a local and a domain part.
The local-part of the e-mail address may use any of these ASCII characters:
• Uppercase and lowercase English letters (a-z, A-Z)
• Digits 0 through 9
• Characters ! # $ % & ' * + - / = ? ^ _ ` { | } ~
• Character . provided that it is not the first nor last character, nor may it appear two or more times consecutively.
I added some more tests to RameshBabu's function.

Code: Select all

//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


Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
Post Reply