com.sanctionco.jmail

What is it

com.sanctionco.jmail parses and validates email addresses.

Why use it

Web applications often need to work with email addresses in some form.

If you find yourself needing to check if something is a valid email address, jmail is more correct than the alternatives and generally around twice as fast..

If you find yourself wanting to represent an email address in your domain, the Email type provided by this library will serve you well. You'd want to use that over a String for the same reason you'd want to store a path in a Path or an address in a URI.

Getting Started

import com.sanctionco.jmail.Email;
import com.sanctionco.jmail.JMail;

void main() {
    // false
    System.out.println(JMail.isValid("gibberish"));

    // true
    System.out.println(JMail.isValid("apple@example.com"));

    Email email = Email.of("apple@example.com")
            .orElseThrow();

    record User(Email email) {
    }

    User user = new User(email);

    // User[email=apple@example.com]
    System.out.println(user);

    // example.com
    System.out.println(user.email().domain());
}

<- Index