Added a static method to normalize an email address.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@1835 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2006-04-28 22:00:23 +00:00
parent 38f09416b7
commit c3498b63e2
+13
View File
@@ -52,6 +52,19 @@ public class MailUtil
return _emailre.matcher(address).matches();
}
/**
* @return a normalized form of the specified email address
* (everything after the @ sign is lowercased).
*/
public static String normalizeAddress (String address)
{
// this algorithm is tolerant of bogus input: if address has no
// @ symbol it will cope.
int afterAt = address.indexOf('@') + 1;
return address.substring(0, afterAt) +
address.substring(afterAt).toLowerCase();
}
/**
* Delivers the supplied mail message using the machine's local mail
* SMTP server which must be listening on port 25.