How to implement email check function in android

I am developing an Android application. This application has a registration module. To do this, I need to implement the email verification feature.

Using the following code, I can send an email for a specific email.

  public void onClick(View v) {
            // TODO Auto-generated method stub

            try {   
                GMailSender sender = new GMailSender("username@gmail.com", "*******");
                sender.sendMail("This is Subject",   
                        "This is Body",   
                        "rose.jasmine87@gmail.com",
                        "naresh_bammidi@yahoo.co.in"
                        );   
            } catch (Exception e) {   
                Log.e("SendMail", e.getMessage(), e);   
            } 

        }

but how do you know the status, was it sent or not?

+3
source share
2 answers

I assume that you are using GMailSender as indicated in this publication.

GMailSender Transport.send(), , GMail , , , . -, GMailSender, - .

, , GMail. , GMail, , , . , , , .

RFC 1891 SMTP, , . , , , , . , , , , . , , , , .

, , , . SMTPMessage , "Return-Receipt-To", . NotifyOptions() , GMail. .

. , , . , , , , , URI, , . URI , . , . - C2DM, , .

, , , , , , , .

+2

, , , , .

public boolean isEmail(String email)
{
    boolean matchFound1;
    boolean returnResult=true;
    email=email.trim();
    if(email.equalsIgnoreCase(""))
        returnResult=false;
    else if(!Character.isLetter(email.charAt(0)))
        returnResult=false;
    else 
    {
        Pattern p1 = Pattern.compile("^\\.|^\\@ |^_");
        Matcher m1 = p1.matcher(email.toString());
        matchFound1=m1.matches();

        Pattern p = Pattern.compile("^[a-zA-z0-9._-]+[@]{1}+[a-zA-Z0-9]+[.]{1}+[a-zA-Z]{2,4}$");
        // Match the given string with the pattern
        Matcher m = p.matcher(email.toString());

        // check whether match is found
        boolean matchFound = m.matches();

        StringTokenizer st = new StringTokenizer(email, ".");
        String lastToken = null;
        while (st.hasMoreTokens()) 
        {
            lastToken = st.nextToken();
        }
        if (matchFound && lastToken.length() >= 2
        && email.length() - 1 != lastToken.length() && matchFound1==false) 
        {

           returnResult= true;
        }
        else returnResult= false;
    }
    return returnResult;
 }
0

All Articles