com.sanctionco.jmail/jmail
com.sanctionco.jmail
RohanNagar/jmail
com.sanctionco.jmail
parses and validates email addresses.
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
.
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.of("apple@example.com")
Email email .orElseThrow();
User(Email email) {
record }
= new User(email);
User user
// User[email=apple@example.com]
System.out.println(user);
// example.com
System.out.println(user.email().domain());
}