Use the following language-specific implementations to ensure RFC-compliant email validation that supports all valid gTLDs.
<!-- HTML5 -->
<input type="email" name="email" required>
// PHP
$valid = filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
# Python
from email_validator import validate_email
result = validate_email("user@example.pizza")
// JS / TS
import validator from 'validator';
validator.isEmail('user@example.pizza'); // true
# Ruby
valid = email.match?(URI::MailTo::EMAIL_REGEXP)
// Java
import jakarta.mail.internet.InternetAddress;
InternetAddress addr = new InternetAddress(email);
addr.validate();
// C#
try {
var addr = new System.Net.Mail.MailAddress(email);
bool valid = addr.Address == email;
} catch (FormatException) { /* invalid */ }
// Go
import "net/mail"
_, err := mail.ParseAddress(email)
valid := err == nil
// Swift
import Foundation
let detector = try NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
let range = NSRange(email.startIndex..<email.endIndex, in: email)
let match = detector.firstMatch(in: email, options: [], range: range)
let valid = match?.url?.scheme == "mailto"
// Kotlin (Android)
val valid = android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()
// Kotlin (JVM)
val addr = jakarta.mail.internet.InternetAddress(email)
addr.validate()
// Rust
use email_address::EmailAddress;
let valid = EmailAddress::is_valid("user@example.pizza");
# Elixir (Ecto changeset)
validate_format(changeset, :email, ~r/^[^ ]+@[^ ]+\.[^ ]+$/)