public static Message newMessage(Stream stream) throws Malformed { return newMessage(stream, null, null); }
public static Message newMessage(Stream stream, Address from, Address to) throws Malformed {
- if (from == null && to == null) return newMessage(stream);
+ if (from == null && to == null) return new Message(stream);
StringBuffer sb = new StringBuffer();
boolean inheaders = true;
- if (from != null) sb.append("Return-Path: " + from.toString(true));
+ if (from != null) sb.append("Return-Path: " + from.toString(true) + "\r\n");
while(true) {
String s = stream.readln();
if (s == null) break;
if (inheaders && to != null && s.toLowerCase().startsWith("envelope-to:")) continue;
if (inheaders && from != null && s.toLowerCase().startsWith("return-path:")) continue;
- if (s.length() == 0) {
+ if (s.length() == 0 && inheaders) {
inheaders = false;
if (to != null) sb.append("Envelope-To: " + to.toString(true) + "\r\n");
}
public void dump(Stream s) {
s.setNewline("\r\n");
s.println(headers.raw);
- s.println();
+ s.println("");
s.println(body);
s.flush();
}
public Listener(Login l) { this.login = l; }
private void println(String s) { Log.warn("[nntp-write]", s); conn.println(s); }
- private void println() { Log.warn("[nntp-write]", ""); conn.println(); }
+ private void println() { Log.warn("[nntp-write]", ""); conn.println(""); }
private void article(String numOrMessageId, boolean head, boolean body) {
String s = numOrMessageId.trim();
}
private static void check(String s, Connection conn) {
- while (s.charAt(3) == '-') s = conn.readln();
+ while (s.length() > 3 && s.charAt(3) == '-') s = conn.readln();
if (s.startsWith("4")||s.startsWith("5")) throw new SMTPException(s);
}
private static boolean attempt(final Message m, final InetAddress mx) {