I successfully done validation of mail address
but I want some suggestions for verifying an email address. The main point is when user enter an email id it should b checked that it is real or just a fake id.
Any suggestion?
Asked
Active
Viewed 6,608 times
3

Himanshu
- 31,810
- 31
- 111
- 133

Sneha Jain
- 25
- 2
- 5
-
3you can use regular expression for setting validation rule http://www.mkyong.com/regular-expressions/10-java-regular-expression-examples-you-should-know/ but knowing for sure that email id is correct is not possible I guess – Sunny Kumar Aditya Nov 10 '12 at 05:49
-
you mean validate? btw! what you have tried? – RobinHood Nov 10 '12 at 05:50
-
I dont want to validate coz i hv done this already. i just want to check that entered email address exists or not.Thats it. – Sneha Jain Nov 10 '12 at 05:58
4 Answers
1
No, this facility is not available. You can verify only when you have your own mail server the you are authorized to check the mail id is valid or not. Or when you own other server then you are permitted to get the mirror image of all others mail server only then you can verify, So if you are just a user of mail id then you can verify that the mail id is valid or not.
You can only verify the correct format of mail id by pattern checking.
Have fun

Varun Vishnoi
- 980
- 1
- 9
- 32
-
Actually in my app i am just taking an email address from user and just want to check that it exists or not.Nothing else. Coz sumtimes user jss enters the fake address and i dont want user to do this. – Sneha Jain Nov 10 '12 at 06:00
-
@SnehaJain you cant do that because no mail server permits to check their mail id details. you can have mirror image of that portion only when you have their own mail server and that is paid... so you cant.\ – Varun Vishnoi Nov 10 '12 at 06:03
-
Let me explain clearly.. U all see websites which ask u for login from diffrent sites.like login from facebook,login from gmail etc. so i just want that when user enter his/her email address then it should exist. – Sneha Jain Nov 10 '12 at 06:27
-
@SnehaJain that works from mirror image of mail servers. those are connected from each other and totally transparent. If you want to validate a mail id that the mail id exists or not then you have to take the permission from the mail server like gmail, yahoo etc. which is paid – Varun Vishnoi Nov 10 '12 at 06:31
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
-
This is absolutely correct; mail servers do not allow you to collect this data. (*Hence why you get a PostMaster message back when you send to a bogus email.*) – Cat Nov 10 '12 at 06:08
-
Let me explain clearly.. U all see websites which ask u for login from diffrent sites.like login from facebook,login from gmail etc. so i just want that when user enter his/her email address then it should exist. – Sneha Jain Nov 10 '12 at 06:27
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.

Nipun Gogia
- 1,846
- 1
- 11
- 17
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);

Nipun Gogia
- 1,846
- 1
- 11
- 17