我成功完成了validation of mail address
,但我想要一些关于验证电子邮件地址的建议。要点是当用户输入电子邮件 ID 时,应该检查它是真实的还是只是假的 ID。有什么建议吗?
问问题
6481 次
4 回答
1
You can only check whether entered E-mail id is validate or not
using regular expression, its not possible to check whether id
is exists or not? as per my knowledge.
check out this link its already well answered
于 2012-11-10T05:57:25.827 回答
1
不,此设施不可用。只有当您拥有自己的邮件服务器时,您才能验证您有权检查邮件 ID 是否有效。或者当您拥有其他服务器时,您才可以获取所有其他邮件服务器的镜像,然后您可以验证,因此,如果您只是邮件 ID 的用户,那么您可以验证邮件 ID 是否有效。
您只能通过模式检查来验证邮件 ID 的正确格式。
玩得开心
于 2012-11-10T05:49:08.467 回答
0
public static void main(String[] args) throws Exception {
String email = null;
String dns = null;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter email address to validate: ");
email = reader.readLine();
System.out.print("Enter DNS hostname to perform domain validation (e.g. ns.myhost.com): ");
dns = reader.readLine();
// create EmailInspector instance
EmailInspector inspector = new EmailInspector();
// enable debugging
inspector.setDebug(true);
// set DNS server
inspector.setNameserver(dns);
// set validation level
inspector.setEmailInspectionLevel(inspector.DOMAIN_VALIDATION);
// validate email
inspector.validate(email);
}
}
. Create new EmailInspector instance.
. Enable debugging.
. Set DNS server to be used for looking up domains.
. Set validation level.
. Validate email address.
于 2012-11-30T07:31:42.703 回答
0
Properties props = System.getProperties();
props.put("mail.smtp.user", senderEmail);
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.debug", "true");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
// Required to avoid security exception.
email.MyAuthenticator authentication =
new email.MyAuthenticator(senderEmail,senderMailPassword);
Session session =
Session.getDefaultInstance(props,authentication);
session.setDebug(true);
于 2012-11-30T09:33:15.197 回答