E-mail valiadtion in REXX



IBM's Command List programming language & Restructured Extended Executor

E-mail valiadtion in REXX

Postby Ramsee » Thu Nov 28, 2013 7:48 pm

Hi All,

Good day!

I like to validate an E-mail ID from the Input via REXX, Could you please sugest me how to validate an E-mail ID.

I am not able to find any of the String function to do it so, Please help me which function to be used.

Thanks a ton for the time.

Regrads,
Ramsee
Ramsee
 
Posts: 25
Joined: Wed Nov 20, 2013 6:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: E-mail valiadtion in REXX

 

Re: E-mail valiadtion in REXX

Postby enrico-sorichetti » Thu Nov 28, 2013 7:58 pm

define the meaning of VALIDATE
for example
email = "some_name@some_addr"
parse var email ename @" eaddr

will split the email address into the two components

but until You specify better the requirement
we can only guess, and psychic day will be only next wednesday :geek:
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: E-mail valiadtion in REXX

Postby Ramsee » Thu Nov 28, 2013 8:01 pm

Hi Enrico,

i used the following code which does what i expected, i need to have atlease @ symbol in the E-mail Id which i process,
The use of "_" and "." is an optional but the mandatory was "@" symbol which i have done as below.

IF FIND('@',mail_id) == 0 THEN
DO
SAY 'ENTERED MAIL-ID is invalid:'
CALL PROCESS_EXIT
END

Thanks a ton for your time in helping me..
Have a great day ahead!!

Regards,
Ramsee
Ramsee
 
Posts: 25
Joined: Wed Nov 20, 2013 6:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: E-mail valiadtion in REXX

Postby enrico-sorichetti » Thu Nov 28, 2013 8:14 pm

the proper function to be used is POS

FIND is a NON PORTABLE extension.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: E-mail valiadtion in REXX

Postby Ramsee » Fri Nov 29, 2013 6:40 pm

Hi All,

I have used the below code for the required.

echeck = '0'

echeck = pos('@',mail_id)
IF (echeck = '0') THEN
DO
SAY 'ENTERED MAIL-ID is invalid:'
CALL PROCESS_EXIT
END

Thanks a lot for the suggesstion and help.

Regards,
Ramsee
Ramsee
 
Posts: 25
Joined: Wed Nov 20, 2013 6:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: E-mail valiadtion in REXX

Postby NicC » Fri Nov 29, 2013 7:28 pm

You should not need the initialisation of echeck as POS will return 0 if the '@' is not found. (And why do you init it to character zero ('0') instead of just zero (0)?)

And please use the code tags when posting code.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: E-mail valiadtion in REXX

Postby Pedro » Tue Dec 03, 2013 5:08 am

Could you please sugest me how to validate an E-mail ID.


Sorry, I am not sure if these are actual rules, or only rules that I came up with in my head.

I think the 'some_addr' portion of the email address should be checked for:
1. make sure it contains a period.
2. make sure the period is not the last character
3. no embedded blanks.
4. the only special characters allowed are hyphen and period. do not allow special characters in the domain name, ie: pedro@qmail.c[m
5. a hyphen cannot be the first or last character of a domain label
6. do not exceed 253 characters.
Pedro Vera
User avatar
Pedro
 
Posts: 569
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 39 times

Re: E-mail valiadtion in REXX

Postby KenT » Wed Dec 04, 2013 4:51 am

Those rules are from your own head. Use GOOGLE or any other search engine on just "validating an email address" and you will find 'validate' is far more complex than what you list and the only sure fired way to get 100% success is send the email and ensure it is received. Not get a bounce back is not proof it was received.

Some other loose rules were once that the last part would be no more than 3 characters, like com, org, net. Then all sorts of other TOP LEVEL DOMAIN entities came about. Lots of funky characters are allowed besides the underscore and period. I was experimenting with PowerShell and sample code people believed would work and the most complex validation routine still failed to identify a valid email address from a bad one. Thought it had a high success rate, it was also a CPU burner compared to 'at least one period after the @'.

An earlier suggestion was leading you to code:

IF (pos('@',mail_id) = 0) THEN
DO
SAY 'ENTERED MAIL-ID is invalid:'
CALL PROCESS_EXIT
END

Note POS returns a numeric, so no need to put apostrophes around the zero.
KenT
 
Posts: 2
Joined: Tue Dec 03, 2013 11:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: E-mail valiadtion in REXX

Postby Pedro » Wed Dec 04, 2013 6:59 am

Those rules are from your own head.

Yeah, I knew I was writing about something that I do not know very much about. But I wanted to point out that, per the poster's requirement of validating an email address, there is much more work to do.

When I read " please sugest me how to validate an E-mail ID", I took it to ask about validating the -format- of an email address. As you point out, it still will not guarantee that it is an active email address.
Pedro Vera
User avatar
Pedro
 
Posts: 569
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 39 times

Re: E-mail valiadtion in REXX

Postby creiglee » Tue Sep 06, 2016 10:49 am

try use regex for ...validating email address

Lee

(Try not to reply to a thread that's been quiescent for over two and a half years.)
creiglee
 
Posts: 1
Joined: Tue Sep 06, 2016 10:48 am
Has thanked: 0 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post