- journal_msg->cm_fields['J'] = strdup("is journal");
- journal_msg->cm_fields['A'] = jmsg->from;
- journal_msg->cm_fields['N'] = jmsg->node;
- journal_msg->cm_fields['F'] = jmsg->rfca;
- journal_msg->cm_fields['U'] = jmsg->subj;
-
- sprintf(mime_boundary, "--Citadel-Journal-%08lx-%04x--", time(NULL), ++seq);
- message_text = malloc(strlen(jmsg->rfc822) + sizeof(struct recptypes) + 1024);
-
- sprintf(message_text,
- "Content-type: multipart/mixed; boundary=\"%s\"\r\n"
- "MIME-Version: 1.0\r\n"
- "\n"
- "--%s\r\n"
- "Content-type: text/plain\r\n"
- "\r\n"
- "Sender: %s "
- ,
- mime_boundary,
- mime_boundary,
- ( journal_msg->cm_fields['A'] ? journal_msg->cm_fields['A'] : "(null)" )
- );
-
- if (journal_msg->cm_fields['F']) {
- sprintf(&message_text[strlen(message_text)], "<%s>",
- journal_msg->cm_fields['F']);
+ CM_SetField(journal_msg, eJournal, HKEY("is journal"));
+ CM_SetField(journal_msg, eAuthor, jmsg->from, strlen(jmsg->from));
+ CM_SetField(journal_msg, eNodeName, jmsg->node, strlen(jmsg->node));
+ CM_SetField(journal_msg, erFc822Addr, jmsg->rfca, strlen(jmsg->rfca));
+ CM_SetField(journal_msg, eMsgSubject, jmsg->subj, strlen(jmsg->subj));
+
+ mblen = snprintf(mime_boundary, sizeof(mime_boundary),
+ "--Citadel-Journal-%08lx-%04x--", time(NULL), ++seq);
+ rfc822len = strlen(jmsg->rfc822);
+
+ message_text = NewStrBufPlain(NULL, rfc822len + sizeof(recptypes) + 1024);
+
+ /*
+ * Here is where we begin to compose the journalized message.
+ * NOTE: the superfluous "Content-Identifer: ExJournalReport" header was
+ * requested by a paying customer, and yes, it is intentionally
+ * spelled wrong. Do NOT remove or change it.
+ */
+ StrBufAppendBufPlain(
+ message_text,
+ HKEY("Content-type: multipart/mixed; boundary=\""), 0);
+
+ StrBufAppendBufPlain(message_text, mime_boundary, mblen, 0);
+
+ StrBufAppendBufPlain(
+ message_text,
+ HKEY("\"\r\n"
+ "Content-Identifer: ExJournalReport\r\n"
+ "MIME-Version: 1.0\r\n"
+ "\n"
+ "--"), 0);
+
+ StrBufAppendBufPlain(message_text, mime_boundary, mblen, 0);
+
+ StrBufAppendBufPlain(
+ message_text,
+ HKEY("\r\n"
+ "Content-type: text/plain\r\n"
+ "\r\n"
+ "Sender: "), 0);
+
+ if (CM_IsEmpty(journal_msg, eAuthor))
+ StrBufAppendBufPlain(
+ message_text,
+ journal_msg->cm_fields[eAuthor], -1, 0);
+ else
+ StrBufAppendBufPlain(
+ message_text,
+ HKEY("(null)"), 0);
+
+ if (!CM_IsEmpty(journal_msg, erFc822Addr)) {
+ StrBufAppendPrintf(message_text, " <%s>",
+ journal_msg->cm_fields[erFc822Addr]);