- public String toString() { return description.equals("") ? (user +"@"+ host) : description+" <" + user +"@"+ host + ">"; }
- public static class Malformed extends MailException.Malformed { public Malformed(String s) { super(s); } }
+ public String toString(boolean desc) {
+ return desc && description != null && description.length() > 0 ? (description+" <" + toString() + ">") : toString(); }
+ public static class Malformed extends Message.Malformed { public Malformed(String s) { super(s); } }
+
+ public boolean isLocal() {
+ InetAddress[] mx = SMTP.getMailExchangerIPs(host);
+ for(int i=0; i<mx.length; i++) {
+ try { if (NetworkInterface.getByInetAddress(mx[i]) != null) { return true; } }
+ catch (Exception e) { /* DELIBERATE */ }
+ }
+ Log.warn(this, "returning false");
+ return false;
+ }
+
+ public static Address[] list(String spec) {
+ if (spec == null) return new Address[] { };
+ StringTokenizer st = new StringTokenizer((String)spec, ",");
+ Address[] ret = new Address[st.countTokens()];
+ for(int i=0; i<ret.length; i++) {
+ String s = st.nextToken();
+ ret[i] = Address.parse(s);
+ if (ret[i] == null) Log.warn(Address.class, "Warning: address " + s + " is unparseable");
+ }
+ return ret;
+ }