I am using this code to send email
Email email = new SimpleEmail();
email.setHostName("smtp.googlemail.com");
email.setSmtpPort(465);
email.setAuthenticator(new DefaultAuthenticator("username", "password"));
email.setSSLOnConnect(true);
email.setFrom("[email protected]");
email.setSubject("TestMail");
email.setMsg("This is a test mail ... :-)");
email.addTo("[email protected]");
email.send();
http://commons.apache.org/proper/commons-email/userguide.html
How can I know if the [email protected] is real email and it receives the messages ?
email.addTo("[email protected]");
There is no reliable way to track email delivery without proprietary APIs and infrastructure. Based only on SMTP, POP and/or IMAP, there is no way to make completely sure, that the email was read.
There are options, however, that might give you some degree of information about the validity of the address (starting with an email address parser), listening to error messages that might get sent from the receiving server (Bounce message) and requesting delivery notifications (Return receipts).
Additionally you could send an HTML email and embed a link to an image and track if the URL has been called. But even this is not reliable, because email clients might not display images, the URL might have been called by a virus scanner etc. That means you might get a lot of false positives / negatives.
You need to use the POP3 capabilities of JavaMail.
You have a sample here: http://alvinalexander.com/java/javamail-pop-pop3-reader-email-inbox-example
I if remember well: server is pop.gmail.com and port is 995.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With