Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
ddev1702
Posts: 64
Registered: ‎04-25-2012
My Device: 9000
My Carrier: Airtel

how to check given email id is valid or not in adobe air for bb playbook?

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.

d.dev
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: how to check given email id is valid or not in adobe air for bb playbook?

That will require your app to have internet connection. It can be tricky to verify there is a record for the domain and then ask the email server if it has a certain accounts. Some email servers will block the query, so all you can verify if the host exists. You can try to connect to the host, but someone could have email, but not a website.

It is best to stay away for MX classes. They are old and may go away at some point. Here is a generic way to check the format (there might be others):

http://cookbooks.adobe.com/post_Validate_email_address_in_Flash___AS3-16298.html

http://www.bokelberg.de/actionscript/checkEmail.html

There might be some services you can use, but make certain they are not an interface to SPAM houses.
Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: how to check given email id is valid or not in adobe air for bb playbook?


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.

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
Developer
ddev1702
Posts: 64
Registered: ‎04-25-2012
My Device: 9000
My Carrier: Airtel

Re: how to check given email id is valid or not in adobe air for bb playbook?

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 && ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").indexOf(s.charAt(i)) != -1) {

                        i++;
                    }
                    return i;
                }
                function checkFirstLevelDomainChars (s, i, l) {
                    while (i < l && ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").indexOf(s.charAt(i)) != -1) {
                        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
               

d.dev
Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: how to check given email id is valid or not in adobe air for bb playbook?

[ Edited ]

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.

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: how to check given email id is valid or not in adobe air for bb playbook?

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.
Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: how to check given email id is valid or not in adobe air for bb playbook?


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.

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
Developer
steve_web
Posts: 321
Registered: ‎05-07-2009
My Device: BlackBerry Z10, PlayBook, 9900
My Carrier: Telus

Re: how to check given email id is valid or not in adobe air for bb playbook?

Agreed. The best you can do is verify the format (and if you choose the domain).

If you really want to make sure... Send a confirmation email to the account when the user enters it willing fully.

In the email have a link / confirmation code that they can click on /type in on your site.

With this you can verify that the email address exists... BUT... Beware that that is only correct for that moment in time.

This could be a burner email account that only exists for 10 minutes... Or a spam prevention account like a mailinator account.

Regardless be respectful of the end users inbox.. If you have messages to send them that are wanted/related to your service that's fine but don't spam their account with ads.

But in full truth... You can't tell for sure that an email address fully, truly, 100% for certain exists... And most attempts to do so are futile. Sorry.

PlayBook Apps: DataMine, Dots + Boxes, 5 Marbles
BlackBerry SmartPhone Apps: 5 Marbles Soon: **** (D.Z.A), ****Quest, **** Challenge, VaultCracker, DevBrowser, Radial****
Please use plain text.
Developer
ddev1702
Posts: 64
Registered: ‎04-25-2012
My Device: 9000
My Carrier: Airtel

Re: how to check given email id is valid or not in adobe air for bb playbook?

yes!this is exactly whats going on.it is just checking the @  and ".com".nothing else

 

d.dev
Please use plain text.
Developer
ddev1702
Posts: 64
Registered: ‎04-25-2012
My Device: 9000
My Carrier: Airtel

Re: how to check given email id is valid or not in adobe air for bb playbook?

@steve_web thank u for all ur valuable suggestion!but can u tell me how to send that link or confirmation code to user account and from that how can i verify their accounts existance?
May be this question sounds very foolish,but really i dnt have any idea!i am new in this !!
d.dev
Please use plain text.