}
}
// We will rebuild the header object to put Return-Path and our
// Received header at the top
Enumeration headerLines = headers.getAllHeaderLines();
MailHeaders newHeaders = new MailHeaders();
// Put the Return-Path first
// JAMES-281 fix for messages that improperly have multiple
// Return-Path headers
StringTokenizer tokenizer = new StringTokenizer(returnPath, "\r\n");
while(tokenizer.hasMoreTokens()) {
String path = tokenizer.nextToken();
newHeaders.addHeaderLine(RFC2822Headers.RETURN_PATH + ": " + path);
}
// Put our Received header next
headerLineBuffer.append(RFC2822Headers.RECEIVED + ": from ")
.append(remoteHost)
.append(" ([")
.append(remoteIP)
.append("])");
newHeaders.addHeaderLine(headerLineBuffer.toString());
headerLineBuffer.delete(0, headerLineBuffer.length());
headerLineBuffer.append(" by ")
.append(theConfigData.getHelloName())
.append(" (")
.append(SOFTWARE_TYPE)
.append(") with SMTP ID ")
.append(smtpID);
if (((Collection) state.get(RCPT_LIST)).size() == 1) {
// Only indicate a recipient if they're the only recipient
// (prevents email address harvesting and large headers in
// bulk email)
newHeaders.addHeaderLine(headerLineBuffer.toString());
headerLineBuffer.delete(0, headerLineBuffer.length());
headerLineBuffer.append(" for <")
.append(((List) state.get(RCPT_LIST)).get(0).toString())
.append(">;");
newHeaders.addHeaderLine(headerLineBuffer.toString());
headerLineBuffer.delete(0, headerLineBuffer.length());
} else {
// Put the ; on the end of the 'by' line
headerLineBuffer.append(";");
newHeaders.addHeaderLine(headerLineBuffer.toString());
headerLineBuffer.delete(0, headerLineBuffer.length());
}
headerLineBuffer = null;
newHeaders.addHeaderLine(" " + rfc822DateFormat.format(new Date()));
// Add all the original message headers back in next
while (headerLines.hasMoreElements()) {
newHeaders.addHeaderLine((String) headerLines.nextElement());
}
return newHeaders;
}