Hello,
I need to clean incoming email addresses. Can someone please point me at some code snippets?
All I want is the actual address. e.g.
something@somewhere.com
Reading the RFC and searching on-line an email address can be quite a mess.
See here for starters, page-down x 2:
https://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx/
But I have seen
DesignSpark <designspark@news.rs-online.com> Using nlserver, Build 6.1.1.8705
"B&H Photo" <ord-status@bhphotovideo.com> Using MIME::Lite 3.01 (E2.72; F4.60; Q2.21; G4.21)
It gets complicated fast.
EDIT: I've just read your link.
I didn't know that you could use the @-symbol in the local part if you escape or quote it!! :o :o :o
EDIT: I've just read your link.
I know Indy10
Seems to my simple mind that something as basic as an email address should be defined in the RFC way more rigidly. But what do I know. :)
What are you struggling with?
I am already doing as you suggested and a lot more, but still occasionally get a blank "To" or "From" address meaning my attempts have failed to clean it up.
What are you struggling with?
I was hoping someone had been down this path before and had an all singing, all dancing version that coped with everything.
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
Probably needs some extra escaping to make that work in TRegExpr.