JS m = (JS)a;
StringBuffer headers = new StringBuffer();
String body = "";
+ Address from = null, to = null;
for(Enumeration e = m.keys(); e.hasMoreElements();) {
String key = (String)e.nextElement();
- String val = m.get(key).toString();
- if (key.equals("body")) body = val;
+ String val = m.get(key) == null ? null : m.get(key).toString();
+ if ("body".equals(key)) body = val;
else headers.append(key + ": " + val + "\r\n");
+ if ("from".equalsIgnoreCase(key)) from = Address.parse(val);
+ if ("to".equalsIgnoreCase(key)) to = Address.parse(val);
}
Message message = new Message(new org.ibex.io.Stream(headers.toString() + "\r\n" + body),
- new Message.Envelope(null, null, new Date()));
+ new Message.Envelope(from,
+ to,
+ new Date()));
//org.ibex.mail.protocol.SMTP.Outgoing.accept(message);
boolean ok = org.ibex.mail.protocol.SMTP.Outgoing.attempt(message);
if (!ok) throw new JSExn("SMTP server rejected message");
}
} catch (Exception e) {
Log.warn(this, "ibex."+name+"() threw: " + e);
+ Log.warn(this, e);
if (e instanceof JSExn) throw ((JSExn)e);
throw new JSExn("invalid argument for ibex object method "+name+"()");
}