void network_deliver_digest(SpoolControl *sc);
-void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc);
void network_spool_msg(long msgnum, void *userdata);
/*
* Deliver list messages to everyone on the list ... efficiently
*/
-void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc) {
+void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc, const char *RoomName) {
char *recps = NULL;
size_t recps_len = SIZ;
struct recptypes *valid;
if (valid != NULL) {
valid->bounce_to = strdup(bounce_to);
valid->envelope_from = strdup(bounce_to);
+ valid->sending_room = strdup(RoomName);
CtdlSubmitMsg(msg, valid, NULL, 0);
free_recipients(valid);
}
}
/* Handle delivery */
- network_deliver_list(msg, sc);
+ network_deliver_list(msg, sc, CC->room.QRname);
CtdlFreeMessage(msg);
}
}
DeleteHash(&(*Item)->MailQEntries);
FreeStrBuf(&(*Item)->EnvelopeFrom);
FreeStrBuf(&(*Item)->BounceTo);
+ FreeStrBuf(&(*Item)->SenderRoom);
FreeURL(&(*Item)->URL);
free(*Item);
Item = NULL;
StrBufAppendBuf(QMessage, MyQItem->EnvelopeFrom, 0);
}
+ if (StrLength(MyQItem->SenderRoom) > 0) {
+ StrBufAppendBufPlain(QMessage, HKEY("\nsource_room|"), 0);
+ StrBufAppendBuf(QMessage, MyQItem->SenderRoom, 0);
+ }
+
StrBufAppendBufPlain(QMessage, HKEY("\nretry|"), 0);
StrBufAppendPrintf(QMessage, "%ld",
MyQItem->Retry);
StrBufExtract_NextToken(Item->BounceTo, Line, Pos, '|');
}
+void QItem_Handle_SenderRoom(OneQueItem *Item, StrBuf *Line, const char **Pos)
+{
+ if (Item->SenderRoom == NULL)
+ Item->SenderRoom = NewStrBufPlain(NULL, StrLength(Line));
+ StrBufExtract_NextToken(Item->SenderRoom, Line, Pos, '|');
+}
+
void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
{
if (Item->Current == NULL)
StrBufAppendBuf(BounceMB, Msg, 0);
FreeStrBuf(&Msg);
+ if (StrLength(MyQItem->SenderRoom) > 0)
+ {
+ StrBufAppendBufPlain(
+ BounceMB,
+ HKEY("The message was originaly posted in: "), 0);
+ StrBufAppendBuf(BounceMB, MyQItem->SenderRoom, 0);
+ StrBufAppendBufPlain(
+ BounceMB,
+ HKEY("\n"), 0);
+ }
+
/* Attach the original message */
StrBufAppendBufPlain(BounceMB, HKEY("--"), 0);
StrBufAppendBuf(BounceMB, boundary, 0);
Put(QItemHandlers, HKEY("attempted"), QItem_Handle_Attempted, reference_free_handler);
Put(QItemHandlers, HKEY("remote"), QItem_Handle_Recipient, reference_free_handler);
Put(QItemHandlers, HKEY("bounceto"), QItem_Handle_BounceTo, reference_free_handler);
+ Put(QItemHandlers, HKEY("source_room"), QItem_Handle_SenderRoom, reference_free_handler);
Put(QItemHandlers, HKEY("submitted"), QItem_Handle_Submitted, reference_free_handler);
-
smtp_init_spoolout();
CtdlRegisterCleanupHook(smtp_evq_cleanup);
/**<
* 0 = No delivery has yet been attempted
* 2 = Delivery was successful
+ * 3 = Transient error like connection problem. Try next remote if available.
* 4 = A transient error was experienced ... try again later
* 5 = Delivery to this address failed permanently. The error message
* should be placed in the fourth field so that a bounce message may
long ActiveDeliveries;
StrBuf *EnvelopeFrom;
StrBuf *BounceTo;
+ StrBuf *SenderRoom;
ParsedURL *URL;
ParsedURL *FallBackHost;
} OneQueItem;
int qualified_for_journaling = 0;
CitContext *CCC = MyContext();
char bounce_to[1024] = "";
- size_t tmp = 0;
int rv = 0;
syslog(LOG_DEBUG, "CtdlSubmitMsg() called\n");
* contain a recipient.
*/
if ((recps != NULL) && (recps->num_internet > 0)) {
+ StrBuf *SpoolMsg = NewStrBuf();
+ long nTokens;
+
syslog(LOG_DEBUG, "Generating delivery instructions\n");
- instr_alloc = 1024;
- instr = malloc(instr_alloc);
- snprintf(instr, instr_alloc,
- "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
- "bounceto|%s\n",
- SPOOLMIME, newmsgid, (long)time(NULL),
- bounce_to
- );
- if (recps->envelope_from != NULL) {
- tmp = strlen(instr);
- snprintf(&instr[tmp], instr_alloc-tmp, "envelope_from|%s\n", recps->envelope_from);
- }
+ StrBufPrintf(SpoolMsg,
+ "Content-type: "SPOOLMIME"\n"
+ "\n"
+ "msgid|%ld\n"
+ "submitted|%ld\n"
+ "bounceto|%s\n",
+ newmsgid,
+ (long)time(NULL),
+ bounce_to);
- for (i=0; i<num_tokens(recps->recp_internet, '|'); ++i) {
- tmp = strlen(instr);
- extract_token(recipient, recps->recp_internet, i, '|', sizeof recipient);
- if ((tmp + strlen(recipient) + 32) > instr_alloc) {
- instr_alloc = instr_alloc * 2;
- instr = realloc(instr, instr_alloc);
+ if (recps->envelope_from != NULL) {
+ StrBufAppendBufPlain(SpoolMsg, HKEY("envelope_from|"), 0);
+ StrBufAppendBufPlain(SpoolMsg, recps->envelope_from, -1, 0);
+ StrBufAppendBufPlain(SpoolMsg, HKEY("\n"), 0);
+ }
+ if (recps->sending_room != NULL) {
+ StrBufAppendBufPlain(SpoolMsg, HKEY("source_room|"), 0);
+ StrBufAppendBufPlain(SpoolMsg, recps->sending_room, -1, 0);
+ StrBufAppendBufPlain(SpoolMsg, HKEY("\n"), 0);
+ }
+
+ nTokens = num_tokens(recps->recp_internet, '|');
+ for (i = 0; i < nTokens; i++) {
+ long len;
+ len = extract_token(recipient, recps->recp_internet, i, '|', sizeof recipient);
+ if (len > 0) {
+ StrBufAppendBufPlain(SpoolMsg, HKEY("remote|"), 0);
+ StrBufAppendBufPlain(SpoolMsg, recipient, len, 0);
+ StrBufAppendBufPlain(SpoolMsg, HKEY("|0||\n"), 0);
}
- snprintf(&instr[tmp], instr_alloc - tmp, "remote|%s|0||\n", recipient);
}
imsg = malloc(sizeof(struct CtdlMessage));
imsg->cm_fields['U'] = strdup("QMSG");
imsg->cm_fields['A'] = strdup("Citadel");
imsg->cm_fields['J'] = strdup("do not journal");
- imsg->cm_fields['M'] = instr; /* imsg owns this memory now */
+ imsg->cm_fields['M'] = SmashStrBuf(&SpoolMsg); /* imsg owns this memory now */
CtdlSubmitMsg(imsg, NULL, SMTP_SPOOLOUT_ROOM, QP_EADDR);
CtdlFreeMessage(imsg);
}
char *display_recp;
char *bounce_to;
char *envelope_from;
+ char *sending_room;
};
#define RECPTYPES_MAGIC 0xfeeb
phase of the SMTP transaction. If an envelope sender is not supplied,
one is extracted from the message body.
+ INSTRUCTION: source_room
+ SYNTAX: source_room|Citadel Support
+ DESCRIPTION:
+ when sending mailinglist rooms this contains the source room for displaying
+ and messaging purposes.
+
+
+
+
-- Once per Remote-part per Queue-Item --
INSTRUCTION: remote
/**<
* 0 = No delivery has yet been attempted
* 2 = Delivery was successful
+ * 3 = Transient error like connection problem. Try next remote if available.
* 4 = A transient error was experienced ... try again later
* 5 = Delivery to this address failed permanently. The error message
* should be placed in the fourth field so that a bounce message may
long ActiveDeliveries;
StrBuf *EnvelopeFrom;
StrBuf *BounceTo;
+ StrBuf *SenderRoom;
ParsedURL *URL;
ParsedURL *FallBackHost;
} OneQueItem;
DeleteHash(&(*Item)->MailQEntries);
FreeStrBuf(&(*Item)->EnvelopeFrom);
FreeStrBuf(&(*Item)->BounceTo);
+ FreeStrBuf(&(*Item)->SenderRoom);
FreeURL(&(*Item)->URL);
free(*Item);
Item = NULL;
OneQueItem *Item = (OneQueItem*) CTX;
StrBufAppendTemplate(Target, TP, Item->EnvelopeFrom, 0);
}
+void tmplput_MailQSourceRoom(StrBuf *Target, WCTemplputParams *TP)
+{
+ OneQueItem *Item = (OneQueItem*) CTX;
+ StrBufAppendTemplate(Target, TP, Item->SenderRoom, 0);
+}
+
+int Conditional_MailQ_HaveSourceRoom(StrBuf *Target, WCTemplputParams *TP)
+{
+ OneQueItem *Item = (OneQueItem*) CTX;
+ return StrLength(Item->SenderRoom) > 0;
+}
+
void tmplput_MailQRetry(StrBuf *Target, WCTemplputParams *TP)
{
char datebuf[64];
StrBufExtract_NextToken(Item->BounceTo, Line, Pos, '|');
}
+void QItem_Handle_SenderRoom(OneQueItem *Item, StrBuf *Line, const char **Pos)
+{
+ if (Item->SenderRoom == NULL)
+ Item->SenderRoom = NewStrBufPlain(NULL, StrLength(Line));
+ StrBufExtract_NextToken(Item->SenderRoom, Line, Pos, '|');
+}
+
void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
{
if (Item->Current == NULL)
Put(QItemHandlers, HKEY("attempted"), QItem_Handle_Attempted, reference_free_handler);
Put(QItemHandlers, HKEY("remote"), QItem_Handle_Recipient, reference_free_handler);
Put(QItemHandlers, HKEY("bounceto"), QItem_Handle_BounceTo, reference_free_handler);
+ Put(QItemHandlers, HKEY("source_room"), QItem_Handle_SenderRoom, reference_free_handler);
Put(QItemHandlers, HKEY("submitted"), QItem_Handle_Submitted, reference_free_handler);
WebcitAddUrlHandler(HKEY("display_smtpqueue"), "", 0, display_smtpqueue, 0);
RegisterNamespace("MAILQ:ATTEMPTED", 0, 0, tmplput_MailQAttempted, NULL, CTX_MAILQITEM);
RegisterNamespace("MAILQ:SUBMITTED", 0, 0, tmplput_MailQSubmitted, NULL, CTX_MAILQITEM);
RegisterNamespace("MAILQ:ENVELOPEFROM", 0, 1, tmplput_MailQEnvelopeFrom, NULL, CTX_MAILQITEM);
+ RegisterNamespace("MAILQ:SRCROOM", 0, 1, tmplput_MailQSourceRoom, NULL, CTX_MAILQITEM);
+ RegisterConditional(HKEY("COND:MAILQ:HAVESRCROOM"), 0, Conditional_MailQ_HaveSourceRoom, CTX_MAILQITEM);
RegisterNamespace("MAILQ:RETRY", 0, 0, tmplput_MailQRetry, NULL, CTX_MAILQITEM);
RegisterNamespace("MAILQ:RCPT:ADDR", 0, 1, tmplput_MailQRCPT, NULL, CTX_MAILQ_RCPT);
<?MAILQ:ID></td>
<td><?MAILQ:SUBMITTED></td>
<td><?MAILQ:RETRY></td>
-<td><?MAILQ:BOUNCETO()><br><?MAILQ:ENVELOPEFROM()></td>
+<td><?MAILQ:BOUNCETO()><br><?MAILQ:ENVELOPEFROM()><?!("COND:MAILQ:HAVESRCROOM", 1)><br><?_("Originaly posted in: ")><?MAILQ:SRCROOM("X")><?!("X", 1)></td>
<td><table class="mailstatus">
<?ITERATE("MAILQ:RCPT", ="view_mailq_recipient")>