- Message message = Message.newMessage(new org.ibex.io.Stream(headers.toString() + "\r\n" + body), from, to);
- //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");
- return JSU.T;
+ if (envelopeTo == null) envelopeTo = to;
+ if (envelopeFrom == null) envelopeFrom = from;
+ Message message =
+ Message.newMessage(new org.ibex.io.Fountain.StringFountain(headers.toString() + "\r\n" + body),
+ envelopeFrom,
+ envelopeTo
+ );
+
+ boolean ok = false;
+ try {
+ if (attempt) {
+ org.ibex.mail.protocol.SMTP.Outgoing.attempt(message);
+ } else {
+ org.ibex.mail.protocol.SMTP.Outgoing.accept(message);
+ }
+ ok = true;
+ } catch (Exception ex) {
+ if (!attempt) Log.warn(this, ex);
+ }
+ if (!ok && !attempt) throw new JSExn("SMTP server rejected message");
+ return JSU.B(ok);
+ }
+ if (name.equals("mail.razor.check")) {
+ Process p = Runtime.getRuntime().exec("razor-check");
+ ((Message)args[0]).getStream().transcribe(new Stream(p.getOutputStream()), true);
+ return JSU.N(p.waitFor());
+ }
+ if (name.equals("mail.dcc.check")) {
+ Process p = Runtime.getRuntime().exec(new String[] { "dccproc", "-H" });
+ ((Message)args[0]).getStream().transcribe(new Stream(p.getOutputStream()), true);
+ StringBuffer ret = new StringBuffer();
+ new Stream(p.getInputStream()).transcribe(ret);
+ p.waitFor();
+ return JSU.S(ret.toString());
+ }
+ if (name.equals("mail.drop")) {
+ return args.length==0 ? new Drop() : new Drop(JSU.toString(args[0]));
+ }
+ if (name.equals("mail.bounce")) {
+ return new JSTarget() {
+ public void accept(Message m) throws MailException {
+ try {
+ Message m2 = m.bounce(JSU.toString(a));
+ org.ibex.mail.protocol.SMTP.Outgoing.accept(m2);
+ Log.error(this, "BOUNCING! " + m2.summary());
+ } catch (Exception e) {
+ Log.warn(this, e);
+ }
+ } };