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.
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:
package com.example;
import java.util.Properties;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.PasswordAuthentication;
import android.util.Log;
public class ImapClient extends javax.mail.Authenticator
{
private static String mailHost="pop3.mail.yahoo.com";
private static Session session;
private static final String uname="myusername@yahoo.com";
private static final String pass="myapss";
public String[] getMail() throws MessagingException
{
Properties props=new Properties();
props.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.pop3.socketFactory.fallback", "false");
props.setProperty("mail.pop3.port", "995");
props.setProperty("mail.pop3.socketFactory.port", "995");
session=Session.getDefaultInstance(props,this);
Store store=session.getStore("pop3");
store.connect(mailHost,uname, pass);
Folder folder=store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
Message[] message =folder.getMessages();
String[] titles=new String[message.length];
for(int i=0,n=message.length;i<n;i++)
{
Log.v("Imap Clinet","Fetching Titles");
titles[i]=message[i].getSubject();
}
folder.close(false);
store.close();
return titles;
}
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(uname, pass);
}
}