Archived Forum Post

Index of archived forum posts

Question:

Mail class, address validation

Jun 26 '17 at 11:56

Howdy,

I'd like to know if chilkat has any class/method to validate the address, for example:

kkk dd@domain.tld <= should return false for validation kkk-dd@domain.tld <= should return true รงรงรง-dd@domain.tld <= should return false

Jorge,


Answer

No. See the following: http://www.chilkatforum.com/questions/1394/validate-email-addresses


Answer

Perfect email address validation is impossible. Some people want syntactic validation, but as Tracy indicated in the link above, there is really no way to do that because there are situations where the "email address" could be a distribution list, an x400 email address, etc. Maybe your app just wants to make sure there's an "@" symbol followed by what looks like a domain..

The other validation is when you contact the SMTP server that owns the email address and you begin an SMTP session and issue the "RCPT TO" command -- to see how the SMTP server responds. For example, maybe you contact smtp.xyz.com for email addresses ending in "xyz.com". The smtp.xyz.com can only know about the email accounts under its control. smtp.xyz.com would know nothing about gmail.com email addresses, or chilkatsoft.com email addresses. Furthermore, there are two problems with trying to validate an email address in this way:

  1. Most SMTP servers won't want to provide this information, which helps spammers determine what are valid/invalid addresses. They'll just respond to the "RCPT TO" command with a success response status, and allow for the email to continue. Then.. afterwards, an NDR may or may not be sent.
  2. Initiating an SMTP sesssion and then stopping prematurely is bad practice and can get your IP address banned for suspicious spammer-like activity.

Basically, for email address validation, my answer is: fuggedaboutit

Have a process in place to handle the NDRs (bounce messages) to update your lists.


Answer

Hi,

I just want to validade the address, not againts the servers.

The's so many functions on the web and regex's for it, but all fail some stuff. For example there's the .net way, which fails for me, even that is valid, that is allowing spaces in the local part. MS Way:

Dim mailAddress As MailAddress Try mailAddress = New MailAddress("testing@invalid@email.com") Catch ex As Exception 'Invalid email End Try