Valid email address

Valid email address

Postby Otto » Fri Apr 10, 2009 3:24 pm

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
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: Valid email address

Postby ukoenig » Fri Apr 10, 2009 7:55 pm

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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Valid email address

Postby RAMESHBABU » Sat Apr 11, 2009 2:58 am

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  Expand view

******************************************************************************
** 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
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Valid email address

Postby Otto » Sat Apr 11, 2009 5:42 am

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
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: Valid email address

Postby ukoenig » Sat Apr 11, 2009 8:00 am

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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Valid email address

Postby IBTC » Sat Apr 11, 2009 8:02 am

Otto wrote:Are these your own functions:
FT_NOOCCUR


This function is from Nanforum Toolkit: http://www.somers.com.br/cgi-bin/w3ng.cgi?nanforlinux.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
IBTC
 
Posts: 103
Joined: Sat Oct 18, 2008 8:13 pm
Location: Stuttgart, Germany

Re: Valid email address

Postby nageswaragunupudi » Sat Apr 11, 2009 8:35 am

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
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Valid email address

Postby RAMESHBABU » Sat Apr 11, 2009 2:31 pm

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
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Valid email address

Postby Otto » Sat Apr 11, 2009 5:28 pm

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
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: Valid email address

Postby Badara Thiam » Sat Apr 11, 2009 5:56 pm

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
Badara Thiam
 
Posts: 160
Joined: Tue Oct 18, 2005 10:21 am
Location: France

Re: Valid email address

Postby RAMESHBABU » Sun Apr 12, 2009 1:09 am

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
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Valid email address

Postby sygecom » Sun Apr 12, 2009 3:13 am

Hello,
Here's an example:

Code: Select all  Expand view
****************************
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
sygecom
 
Posts: 51
Joined: Tue Mar 11, 2008 3:18 am
Location: Brasil

Re: Valid email address

Postby nageswaragunupudi » Sun Apr 12, 2009 3:31 am

The above function returns Valid for the following email address. Can this be right ?
Code: Select all  Expand view

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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Valid email address

Postby hua » Sun Apr 12, 2009 5:53 am

IBTC wrote:This function is from Nanforum Toolkit: http://www.somers.com.br/cgi-bin/w3ng.cgi?nanforlinux.ng+111289


Under xHarbour, Nanforum stuffs are in libnf.lib. Under Harbour it's hbnf.lib
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Valid email address

Postby Otto » Sun Apr 12, 2009 7:39 am

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  Expand view
//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
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 94 guests