- public Mailbox getArchive() throws IOException { return archive; }
-
- public void accept(Message m) throws IOException, MailException {
- StringBuffer buf = new StringBuffer();
- m.getBody().getStream().transcribe(buf);
- Headers head = new Headers.Original(m.headers.getStream());
- head = head.set("List-Id", one_line_description + "<"+address+">");
- head = head.set("Subject", properties.get("prefix") + " " + head.get("Subject"));
-
- m = Message.newMessage(new Fountain.StringFountain(head.getString()+"\r\n"+buf.toString()));
- Log.warn(MailingList.class, "archiving list message " + m.subject);
- getArchive().accept(m);
-
- for(Subscriber s : this) try {
- Log.warn(MailingList.class, " trying " + s.address);
- SMTP.accept(Message.newMessage(m, m.envelopeFrom, s.address));
- Log.warn("[list]", "successfully sent to " + s);
- } catch (Exception e2) { Log.error("[list]", e2); }
+ public void add(Message message) {
+ try {
+ accept(message);
+ } catch (Exception e) { throw new RuntimeException(e); }
+ }
+ public void add(Message message, int flags) { add(message); /* FIXME: flags? */ }
+ public void accept(Message m) throws MailException {
+ try {
+ StringBuffer buf = new StringBuffer();
+ m.getBody().getStream().transcribe(buf);
+ Headers head = new Headers(m.headers,
+ new String[] {
+ "List-Id", one_line_description + "<"+address+">",
+ "Subject", properties.get("prefix") + " " + m.headers.get("Subject")
+ });
+
+ m = Message.newMessage(Fountain.Util.concat(new Fountain[] { head,
+ Fountain.Util.create("\r\n"),
+ Fountain.Util.create(buf.toString()) }));
+ Log.warn(MailingList.class, "archiving list message " + m.subject);
+ mailbox.accept(m);
+
+ for(Subscriber s : subscribers()) try {
+ Log.warn(MailingList.class, " trying " + s.address);
+ SMTP.enqueue(m.withEnvelope(m.envelopeFrom, s.address));
+ Log.warn("[list]", "successfully sent to " + s);
+ } catch (Exception e2) { Log.error("[list]", e2); }
+ } catch (Exception e) { throw new RuntimeException(e); }