Asked  7 Months ago    Answers:  5   Viewed   35 times

What are the good email address validation libraries for Java? Are there any alternatives to commons validator?

 Answers

64

Apache Commons is generally known as a solid project. Keep in mind, though, you'll still have to send a verification email to the address if you want to ensure it's a real email, and that the owner wants it used on your site.

EDIT: There was a bug where it was too restrictive on domain, causing it to not accept valid emails from new TLDs.

This bug was resolved on 03/Jan/15 02:48 in commons-validator version 1.4.1

Tuesday, June 1, 2021
 
Anand
answered 7 Months ago
17

There's ImageJ, which boasts to be the

world's fastest pure Java image processing program

It can be used as a library in another application. It's architecture is not brilliant, but it does basic image processing tasks.

Tuesday, June 1, 2021
 
hillz
answered 7 Months ago
78

Here is my performance test class. Sending the mails using one connection is 4 times faster then reopen the connection every time (what happens when you use commons mail). The performance can be pushed further by using multiple threads.

    Properties properties = System.getProperties();
    properties.put("mail.smtp.host", server);
    properties.put("mail.smtp.port", "" + port);

    Session session = Session.getInstance(properties);
    Transport transport = session.getTransport("smtp");

    transport.connect(server, username, password);

    for (int i = 0; i < count; i++) {

        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress(from));
        InternetAddress[] address = {new InternetAddress(to)};
        message.setRecipients(Message.RecipientType.TO, address);

        message.setSubject(subject + "JavaMail API");
        message.setSentDate(new Date());

        setHTMLContent(message);
        message.saveChanges();
        transport.sendMessage(message, address);

    }

    transport.close();
Saturday, August 14, 2021
 
0skar
answered 4 Months ago
60

I don't know what qualifies as best but zxing has a qr code generator for java, is actively developed, and is liberally licensed.

Friday, September 3, 2021
 
Litty
answered 3 Months ago
51

Currently it is not supported. But it is an open source so, you know what to do...

From the source code:

    private static class OptionComparator
    implements Comparator {

    /**
     * <p>Compares its two arguments for order. Returns a negative 
     * integer, zero, or a positive integer as the first argument 
     * is less than, equal to, or greater than the second.</p>
     *
     * @param o1 The first Option to be compared.
     * @param o2 The second Option to be compared.
     *
     * @return a negative integer, zero, or a positive integer as 
     * the first argument is less than, equal to, or greater than the 
     * second.
     */
    public int compare(Object o1, Object o2)
    {
        Option opt1 = (Option)o1;
        Option opt2 = (Option)o2;

        return opt1.getKey().compareToIgnoreCase(opt2.getKey());
    }
}

You can override the default comparator and define the order you want.

Tuesday, September 28, 2021
 
Leo Odishvili
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share