This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Correct EMail Syntax

Old posts that have not been replied to for several years.
Locked
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Correct EMail Syntax

Post by GodOfSuicide »

I'm currently writing a little script that provides EMail Password recovery etc.
But still i haven't found a way to check if it's really a correct email. I have searched the forum and found some solutions (like [regexp {.+@.+\..+} $arg] from WCC, which i had nearly the same [matchattr $arg *?@?*.?*]).

But still the user can enter invalid email addresses (like my`nick@c§wlhost.d()main).

Does somebody have a proc that checks if ONLY abcde...ABCDE...123, . and @ are used in a string ? would help me a lot.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This should check the correct syntax

Code: Select all


proc chkemail {in} {
  return [regexp {^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$} $in]
}
This will only validate the address to contain the correct chars.

You can go further, and test the address on the spot, to determine if the address has valid NS information and if a mail server is willing to accept mail for this address. This will stop a lot of bounces and spam from the off.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

Big thanks ppslim, works perfekt
Locked