I’m using the below code to validate an email address using Aspose.Email for Java 22.5.
In the documentation located here, it states that in addition to syntax and domain checking it can, “checking user accounts with mail servers”. My question is, how do you do that?
I can get the below code to return ValidationSuccess, SyntaxValidationFailed, and DomainValidationFailed, but I can not get the response code MailServerValidationError. Is more required to perform mail server validation of user accounts? Thanks.
final EmailValidator ev = new EmailValidator();
final ValidationResult[] resultSyntaxAndDomain = new ValidationResult[]{null};
ev.validate(email, ValidationPolicy.SyntaxAndDomain, resultSyntaxAndDomain);
switch (resultSyntaxAndDomain[0].getReturnCode()) {
case ValidationResponseCode.ValidationSuccess:
return “The email address is valid.”;
case ValidationResponseCode.SyntaxValidationFailed:
return “The email address failed syntax validation.”;
case ValidationResponseCode.DomainValidationFailed:
return “The email address failed domain validation.”;
case ValidationResponseCode.MailServerValidationError:
return “The email address failed mail server validation.”;
default:
return “Validation return code invalid.”;
}
Thanks Tahir. Essentially, I was just trying various emails at @gmail.com and @yahoo.com that were syntactically correct but obviously not valid (e.g. blnas3432dfalkajslk3_invalidemail@gmail.com). The above code produces that the email address is valid, which it is syntactically valid, and the domain gmail.com is valid, but I thought this API validated that the email inbox on the server actually existed?
We have logged a ticket as EMAILJAVA-35101 in our issue tracking system for this case. We will inform you via this forum thread once there is an update available on it.
Currently, EMAILJAVA-35101 is pending for analysis and is in the queue. Once we complete the analysis of it, we will then be able to provide you an estimate.
It is to inform you that we have closed the issue EMAILJAVA-35101. We marked SyntaxAndDomain setting as obsolete and it will be removed soon. It cannot be fixed due to non standard responses from various mail servers.
Thanks for the update @tahir.manzoor. Quick follow-up question regarding SyntaxAndDomain. Are you saying this API will only support syntax validation in the future? Because currently it will do syntax validation and validate that the domain is valid (i.e. gmail.com is valid but gmail.edu is not valid). That is actually a nice feature that it checks the domain since those both would be syntactically correct emails. I was more asking about mail server validation in which it validated user email accounts at the domain, which does seem more tricky and error prone based on non-standard responses from various mail servers. I guess, just hoping that the basic domain validation checking isn’t dropped.