如何验证电子邮件(Yahoo,Gmail,Hotmail和AOL)的用户名和密码? 应该把cide放到auth电子邮件的哪个位置?
这是我的代码
public class AuthMail
{
public static void authEmail()
{
if(LoginDialog.t_Email.getText().isEmpty())
{
Util.printErrorMessage("Plase Enter an Email Address");
JOptionPane.showMessageDialog(null, "Plase Enter an Email Address", "Error", JOptionPane.ERROR_MESSAGE);
}
else if(LoginDialog.p_Password.getText().isEmpty())
{
System.out.println("Plase Enter Your Password");
JOptionPane.showMessageDialog(null, "Plase Enter Your Password", "Error", JOptionPane.ERROR_MESSAGE);
}
else if(Util.getMailType().equals("GMail"))
{
System.out.println("Logging...");
System.out.println("Attempting connection to GMail...");
}
else if(Util.getMailType().equals("Yahoo"))
{
System.out.println("Logging...");
System.out.println("Attempting connection to Yahoo...");
}
else if(Util.getMailType().equals("Yahoo"))
{
System.out.println("Logging...");
System.out.println("Attempting connection to Hotmail...");
}
else if(Util.getMailType().equals("AOL"))
{
System.out.println("Logging...");
System.out.println("Attempting connection to Aol...");
}
else if(Util.getMailType().equals("Unknown"))
{
System.out.println("Mail Type Unknown");
int var1 = JOptionPane.showConfirmDialog(null, "Email Type Unknown. Did you want to try again?", "Error", JOptionPane.YES_NO_OPTION);
if(var1 == JOptionPane.NO_OPTION)
{
System.exit(0);
}
}
}
}
注意:Util.class由我自己创建。
答案 0 :(得分:1)
使用包含主机,用户和密码的Store.connect方法。您正在收集用户名和密码。主机名在“if”的每个分支中都会有所不同。您可以在JavaMail FAQ中找到常用服务的主机名。