- StrBuf *QMessage;
- HashPos *It;
- const char *Key;
- long len;
- void *vQE;
-
- QMessage = NewStrBufPlain(NULL, SIZ);
- StrBufPrintf(QMessage, "Content-type: %s\n", SPOOLMIME);
-
-// "attempted|%ld\n" "retry|%ld\n",, (long)time(NULL), (long)retry );
- StrBufAppendBufPlain(QMessage, HKEY("\nmsgid|"), 0);
- StrBufAppendPrintf(QMessage, "%ld", MyQItem->MessageID);
-
- if (StrLength(MyQItem->BounceTo) > 0) {
- StrBufAppendBufPlain(QMessage, HKEY("\nbounceto|"), 0);
- StrBufAppendBuf(QMessage, MyQItem->BounceTo, 0);
- }
-
- if (StrLength(MyQItem->EnvelopeFrom) > 0) {
- StrBufAppendBufPlain(QMessage, HKEY("\nenvelope_from|"), 0);
- StrBufAppendBuf(QMessage, MyQItem->EnvelopeFrom, 0);
- }
-
- It = GetNewHashPos(MyQItem->MailQEntries, 0);
- while (GetNextHashPos(MyQItem->MailQEntries, It, &len, &Key, &vQE))
- {
- MailQEntry *ThisItem = vQE;
- int i;
-
- if (!ThisItem->Active)
- continue; /* skip already sent ones from the spoolfile. */
-
- for (i=0; i < ThisItem->nAttempts; i++) {
- StrBufAppendBufPlain(QMessage, HKEY("\nretry|"), 0);
- StrBufAppendPrintf(QMessage, "%ld",
- ThisItem->Attempts[i].retry);
-
- StrBufAppendBufPlain(QMessage, HKEY("\nattempted|"), 0);
- StrBufAppendPrintf(QMessage, "%ld",
- ThisItem->Attempts[i].when);
- }
- StrBufAppendBufPlain(QMessage, HKEY("\nremote|"), 0);
- StrBufAppendBuf(QMessage, ThisItem->Recipient, 0);
- StrBufAppendBufPlain(QMessage, HKEY("|"), 0);
- StrBufAppendPrintf(QMessage, "%d", ThisItem->Status);
- StrBufAppendBufPlain(QMessage, HKEY("|"), 0);
- StrBufAppendBuf(QMessage, ThisItem->StatusMessage, 0);
- }
- DeleteHashPos(&It);
- StrBufAppendBufPlain(QMessage, HKEY("\n"), 0);
- return QMessage;
-}
-
-void FinalizeMessageSend(SmtpOutMsg *Msg)
-{
- int IDestructQueItem;
- HashPos *It;
-
- citthread_mutex_lock(&ActiveQItemsLock);
- Msg->MyQItem->ActiveDeliveries--;
- IDestructQueItem = Msg->MyQItem->ActiveDeliveries == 0;
- citthread_mutex_unlock(&ActiveQItemsLock);
-
- if (IDestructQueItem) {
- int nRemain;
- StrBuf *MsgData;
-
- nRemain = CountActiveQueueEntries(Msg->MyQItem);
-
- if (nRemain > 0)
- MsgData = SerializeQueueItem(Msg->MyQItem);
- /*
- * Uncompleted delivery instructions remain, so delete the old
- * instructions and replace with the updated ones.
- */
- CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, &Msg->MyQItem->QueMsgID, 1, "");
-
- /* Generate 'bounce' messages * /
- smtp_do_bounce(instr); */
- if (nRemain > 0) {
- struct CtdlMessage *msg;
- msg = malloc(sizeof(struct CtdlMessage));
- memset(msg, 0, sizeof(struct CtdlMessage));
- msg->cm_magic = CTDLMESSAGE_MAGIC;
- msg->cm_anon_type = MES_NORMAL;
- msg->cm_format_type = FMT_RFC822;
- msg->cm_fields['M'] = SmashStrBuf(&MsgData);
-
- CtdlSubmitMsg(msg, NULL, SMTP_SPOOLOUT_ROOM, QP_EADDR);
- CtdlFreeMessage(msg);
- }
- It = GetNewHashPos(Msg->MyQItem->MailQEntries, 0);
- citthread_mutex_lock(&ActiveQItemsLock);
- {
- GetHashPosFromKey(ActiveQItems, IKEY(Msg->MyQItem->MessageID), It);
- DeleteEntryFromHash(ActiveQItems, It);
- }
- citthread_mutex_unlock(&ActiveQItemsLock);
- DeleteHashPos(&It);
- }
-
-/// TODO : else free message...
- close(Msg->IO.sock);