11-26-2012 09:13 AM
hi!
i am using mx component Email validator its checking the format of given email id only(i.e a@gmail.com) but not checking whether this email id actually exists or not.so how to do this?
help me!!!
thanks in advance.
11-26-2012 10:02 AM
11-26-2012 04:48 PM
jtegen wrote:
It is best to stay away for MX classes. They are old and may go away at some point.
To clarify...
The MX classes John is referring to are the old Flex 3 components, which are still in Flex 4.x. I don't think they'll go away untill there are Spark components to replace them.
Don't confuse this with MX records, which point to the domain mail server and won't be going anywhere while we still use SMTP to send e-mail. Those are the records you'd need to query the DNS for. You could use the flash.net.DNSResolver class to figure out whether there is a mail server for that domain.
11-27-2012 12:22 AM
Now i am using this code:
protected function checkEmail (e : String) {
var i :int;
var j: int;
var l:int = e.length;
var foundPoint:Boolean = false;
function checkChars (s, i, l) {
while (i < l && ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV
i++;
}
return i;
}
function checkFirstLevelDomainChars (s, i, l) {
while (i < l && ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV
i++;
}
return (i == l);
}
trace(e);
// every email starts with a string
if ((i=checkChars(e, 0, l)) == 0) {
return -1;
}
//init j
j=i;
// followed by an arbitrary number of ("." string) combinations
while (i < l && e.charAt(i) == ".") {
// skip the point
i++;
// if there are no chars, we have an error
if ((j=checkChars(e, i, l)) == i) {
return -2;
}
// else skip the chars
i = j;
}
// then follows the magic @
if (e.charAt(i) != "@"){
return -3;
}
// followed by minimum one string point string
// after the last point minimum 2 characters are allowed
do {
// skip the @ (j == i at the beginning, so it is like i++)
i = j+1;
// do we have more chars ?
j = checkChars(e, i, l);
if (j == i) {
// no more chars found -> error
return -4;
} else if (j == e.length) {
// emailaddress is finished, do we have a first level domain ?
j -= i;
// we have one if it is at least 2 long and consists of the correct characters
if(foundPoint && j>=2 && checkFirstLevelDomainChars(e, i, l)){
return 1
} else {
return -5
}
}
// if we reach the end or don't have a point, we return an error
foundPoint = (e.charAt(j) == ".");
} while (i < l && foundPoint);
return -6;
}
but,my problem is not fixed!!
even if i am giving eee@a.com as email id ...its returning 1.but this email id dsnt exist at all.what should i do to achieve this?plz...help me
11-27-2012 01:06 AM - edited 11-27-2012 01:09 AM
You need to use DNS to check whether the domain exists and has an MX record. You may be able to do this with the flash.net.DNSResolver class. The AIR runtime on Playbook & BB10 is more capable in some respects than other mobile platforms, and you may have DNSResolver support for MX records too.
11-27-2012 08:57 AM
11-27-2012 11:09 AM
jtegen wrote:
Correct me if I am wrong, but checking the MX record in DNS will only tell you if the domain has email defined for it. It will not check for the account for that email domain.
That is correct. But almost no e-mail servers will allow you to check whether an account exists without authentication as it helps spammers. Most just disregard messages to non-existent accounts and don't even bounce the mail. There is virtually no way to know whether the account part of an e-mail address is correct.
11-27-2012 08:13 PM
11-27-2012 11:10 PM
yes!this is exactly whats going on.it is just checking the @ and ".com".nothing else
11-27-2012 11:16 PM