Page 1 of 1

E-mail valiadtion in REXX

PostPosted: Thu Nov 28, 2013 7:48 pm
by Ramsee
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

Re: E-mail valiadtion in REXX

PostPosted: Thu Nov 28, 2013 7:58 pm
by enrico-sorichetti
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:

Re: E-mail valiadtion in REXX

PostPosted: Thu Nov 28, 2013 8:01 pm
by Ramsee
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

Re: E-mail valiadtion in REXX

PostPosted: Thu Nov 28, 2013 8:14 pm
by enrico-sorichetti
the proper function to be used is POS

FIND is a NON PORTABLE extension.

Re: E-mail valiadtion in REXX

PostPosted: Fri Nov 29, 2013 6:40 pm
by Ramsee
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

Re: E-mail valiadtion in REXX

PostPosted: Fri Nov 29, 2013 7:28 pm
by NicC
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.

Re: E-mail valiadtion in REXX

PostPosted: Tue Dec 03, 2013 5:08 am
by Pedro
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.

Re: E-mail valiadtion in REXX

PostPosted: Wed Dec 04, 2013 4:51 am
by KenT
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.

Re: E-mail valiadtion in REXX

PostPosted: Wed Dec 04, 2013 6:59 am
by Pedro
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.

Re: E-mail valiadtion in REXX

PostPosted: Tue Sep 06, 2016 10:49 am
by creiglee
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.)