1. Are you ready for the Galaxy S20? Here is everything we know so far!

Yahoo mail account configuration problem.

Discussion in 'Android Lounge' started by satellitemundo, Aug 18, 2010.

  1. satellitemundo

    Thread Starter

    Hi,

    I am making an application which allows users to see their e-mails on their android device.
    I can configure the gmail account but I can not configure the yahoo account.I know the problem is of protocol name and port number.
    I google a lot but I can not get rid of this problem.

    Can any one tell me the correct configuration settings.
    Code (Text):
    1.  
    2. package com.example;
    3.  
    4.  
    5. import java.util.Properties;
    6.  
    7. import javax.mail.Folder;
    8. import javax.mail.Message;
    9. import javax.mail.MessagingException;
    10. import javax.mail.Session;
    11. import javax.mail.Store;
    12. import javax.mail.PasswordAuthentication;
    13.  
    14. import android.util.Log;
    15.  
    16.  
    17. public class ImapClient extends javax.mail.Authenticator
    18. {
    19.     private static String mailHost="pop3.mail.yahoo.com";
    20.     private static Session session;
    21.     private static final String uname="myusername@yahoo.com";
    22.     private static final String pass="myapss";
    23.    
    24.     public String[] getMail() throws MessagingException
    25.     {
    26.         Properties props=new Properties();
    27.        
    28.         props.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    29.         props.setProperty("mail.pop3.socketFactory.fallback", "false");
    30.         props.setProperty("mail.pop3.port", "995");
    31.         props.setProperty("mail.pop3.socketFactory.port", "995");
    32.        
    33.         session=Session.getDefaultInstance(props,this);
    34.        
    35.         Store store=session.getStore("pop3");
    36.         store.connect(mailHost,uname, pass);
    37.         Folder folder=store.getFolder("INBOX");
    38.         folder.open(Folder.READ_ONLY);
    39.        
    40.         Message[] message =folder.getMessages();
    41.         String[] titles=new String[message.length];
    42.         for(int i=0,n=message.length;i<n;i++)
    43.         {
    44.             Log.v("Imap Clinet","Fetching Titles");
    45.             titles[i]=message[i].getSubject();
    46.         }
    47.         folder.close(false);
    48.         store.close();
    49.         return titles;
    50.     }
    51.    
    52.     protected PasswordAuthentication getPasswordAuthentication()
    53.     {
    54.         return new PasswordAuthentication(uname, pass);
    55.     }
    56. }
    57.  
    58.  
     


Loading...

Share This Page

Loading...