1. mathews rutto
  2. PowerBuilder
  3. Monday, 13 July 2020 09:49 AM UTC

Hello,

I have need help on how to validate the email entered by the user. Am using free form.

with kind regards,

Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 22 November 2022 20:29 PM UTC
  2. PowerBuilder
  3. # 1

You should code it yourself in PowerBuilder so you can easily update it. The rules are:

General layout:

local-part@domain

Local Part:
Can be up to 64 characters.
Allowed: letters, numbers, underscores, periods, and dashes.
First and last must be letter or number.
Some mail servers may allow other special characters.

Domain:
Can be up to 255 characters.
Allowed: letters, numbers, and dashes.
First and last must be letter or number.
There can only be one dot.
Part before the dot must be at least one character.
Part after the dot must be at least two characters.

 

Comment
  1. Miguel Leeuwe
  2. Wednesday, 23 November 2022 11:54 AM UTC
No probs Andreas, I commit the same error many times while I'm answering, someone else has already done it :)
  1. Helpful
  1. Roland Smith
  2. Wednesday, 23 November 2022 12:59 PM UTC
My mistake about domain dots. I wonder if there is a public web service to validate domain extensions.
  1. Helpful 1
  1. Mark Goldsmith
  2. Wednesday, 23 November 2022 16:02 PM UTC
Have a look at this list of REST APIs available to validate e-mail addresses: https://geekflare.com/email-verification-api/

  1. Helpful 2
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 22 November 2022 14:19 PM UTC
  2. PowerBuilder
  3. # 2

You can check the email address to make sure it follows format rules, for example:  username@domain.ext

There is no way to verify the email address actually exists and is active.

Comment
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Tuesday, 22 November 2022 11:22 AM UTC
  2. PowerBuilder
  3. # 3

You can try this also.  In Itemchanged event

ls_email = Data
Do 	
	ls_object_name = Trim(io_string.of_gettoken (ls_email, ","))
	If match(ls_object_name,'^[a-zA-Z0-9][a-zA-Z0-9\-_\.]*\@[a-zA-Z0-9][a-zA-Z0-9\-_\.]*\.[a-zA-Z0-9\-_\.]+[a-zA-Z0-9]+$') = False Then
		Messagebox('Error', 'Id : ' + ls_object_name + ' is invalid'
		Return False
	End If
	
Loop Until ls_email = ""

This code rejects 1.1..@. 

Happiness Always
BKR Sivaprakash

Comment
  1. Benjamin Gaesslein
  2. Wednesday, 23 November 2022 07:31 AM UTC
Doesn't reject 1..1@1_..1 though. :) And underscores are not allowed in the domain part. Printable characters (!#$%&'*+-/=?^_`{|}~) are allowed in the local part but most of those are filtered here.



There's a regex at https://emailregex.com/ that works for most addresses and it is very complicated.
  1. Helpful
  1. Sivaprakash BKR
  2. Wednesday, 23 November 2022 12:45 PM UTC
Any regular expression will be 99.99% only [ as per your link].
  1. Helpful
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Tuesday, 22 November 2022 06:40 AM UTC
  2. PowerBuilder
  3. # 4

Mathews,
Just came through this email validations
https://www.atdata.com/email-verification

Seems they have two options.   May be helpful

Happiness Always
BKR Sivaprakash

 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 13 July 2020 13:28 PM UTC
  2. PowerBuilder
  3. # 5

Greetings, Matthews - 

I think you need to tread carefully here because of the increased focus and emphasis on privacy and security that many governments are attempting to regulate via legislation. You can parse the email address and verify that it conforms syntactically to specifications, but that does not ensure the email address is valid.

It will be interesting to learn what others in the PB community have done or are doing.

Regards, John

Comment
  1. Daniel Mullings
  2. Monday, 13 July 2020 20:35 PM UTC
Hi Matthews,

If you download a recent version of PFC, look for the of_iswellformedemailaddress() method in pfc_n_cst_string in pfcapsrv.pbl. That works well for making sure the email is syntactically correct. You can cut and paste the code if you aren't using PFC. As for determining if an email is valid, that's much more difficult. You won't know if it's valid or not until you get some kind of return code from SMTP/IMAP. For example, you wouldn't know up front if daniel.mullings@appeon.com is good or not, it's not by the way. :-)
  1. Helpful 2
  1. Benjamin Gaesslein
  2. Tuesday, 22 November 2022 07:24 AM UTC
Email-address syntax verification is a notoriously tricky problem and of_iswellformedemailaddress is not very good at it. 1.1..@. is a valid address according to of_iswellformedemailaddress. The function commentary claims it "Allows dots but not at the beginning or at the end of local part and not consecutive" but only checks for a dot exactly once using Pos(). On the other hand the function filters out addresses that are actually valid because it assumes that all special characters are only valid inside quotation marks, which isn't true for all of them.
  1. Helpful 1
  1. Kevin Ridley
  2. Tuesday, 22 November 2022 18:53 PM UTC
@Benjamin - while it's not perfect, I think it's a good guide to "roll your own". I don't think there's any silver bullet that works every time, short of sending a test email.
  1. Helpful 1
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.