- /* Strip out the headers (no not amd any other non-instruction) line */
- while (pch != NULL) {
- pch = strchr(pch, '\n');
- if ((pch != NULL) && (*(pch + 1) == '\n')) {
- instr = pch + 2;
- pch = NULL;
- }
- }
- PlainQItem = NewStrBufPlain(instr, -1);
- CtdlFreeMessage(msg);
- MyQItem = DeserializeQueueItem(PlainQItem, msgnum);
- FreeStrBuf(&PlainQItem);
-
- if (MyQItem == NULL) {
- CtdlLogPrintf(CTDL_ERR, "SMTP Queue: Msg No %ld: already in progress!\n", msgnum);
- return; /* s.b. else is already processing... */
- }
-
- /*
- * Postpone delivery if we've already tried recently.
- * /
- if (((time(NULL) - MyQItem->LastAttempt.when) < MyQItem->LastAttempt.retry) && (run_queue_now == 0)) {
- CtdlLogPrintf(CTDL_DEBUG, "SMTP client: Retry time not yet reached.\n");
-
- It = GetNewHashPos(MyQItem->MailQEntries, 0);
- citthread_mutex_lock(&ActiveQItemsLock);
- {
- GetHashPosFromKey(ActiveQItems, IKEY(MyQItem->MessageID), It);
- DeleteEntryFromHash(ActiveQItems, It);
- }
- citthread_mutex_unlock(&ActiveQItemsLock);
- ////FreeQueItem(&MyQItem); TODO: DeleteEntryFromHash frees this?
- DeleteHashPos(&It);
- return;
- }// TODO: reenable me.*/
-
- /*
- * Bail out if there's no actual message associated with this
- */
- if (MyQItem->MessageID < 0L) {
- CtdlLogPrintf(CTDL_ERR, "SMTP Queue: no 'msgid' directive found!\n");
- It = GetNewHashPos(MyQItem->MailQEntries, 0);
- citthread_mutex_lock(&ActiveQItemsLock);
- {
- GetHashPosFromKey(ActiveQItems, IKEY(MyQItem->MessageID), It);
- DeleteEntryFromHash(ActiveQItems, It);
- }
- citthread_mutex_unlock(&ActiveQItemsLock);
- DeleteHashPos(&It);
- ////FreeQueItem(&MyQItem); TODO: DeleteEntryFromHash frees this?
- return;
- }
-
- It = GetNewHashPos(MyQItem->MailQEntries, 0);
- while (GetNextHashPos(MyQItem->MailQEntries, It, &len, &Key, &vQE))
- {
- MailQEntry *ThisItem = vQE;
- CtdlLogPrintf(CTDL_DEBUG, "SMTP Queue: Task: <%s> %d\n", ChrPtr(ThisItem->Recipient), ThisItem->Active);
- }
- DeleteHashPos(&It);
-
- CountActiveQueueEntries(MyQItem);
- if (MyQItem->ActiveDeliveries > 0)
- {
- int i = 1;
- StrBuf *Msg = smtp_load_msg(MyQItem);
- It = GetNewHashPos(MyQItem->MailQEntries, 0);
- while ((i <= MyQItem->ActiveDeliveries) &&
- (GetNextHashPos(MyQItem->MailQEntries, It, &len, &Key, &vQE)))
- {
- MailQEntry *ThisItem = vQE;
- if (ThisItem->Active == 1) {
- CtdlLogPrintf(CTDL_DEBUG, "SMTP Queue: Trying <%s>\n", ChrPtr(ThisItem->Recipient));
- smtp_try(MyQItem, ThisItem, Msg, (i == MyQItem->ActiveDeliveries));
- i++;
+ syslog(LOG_DEBUG, "SMTP Starting: [%ld] <%s> CC <%d> \n",
+ Msg->MyQItem->MessageID,
+ ChrPtr(Msg->MyQEntry->Recipient),
+ ((CitContext*)Msg->IO.CitContext)->cs_pid);
+ if (Msg->pCurrRelay == NULL)
+ QueueEventContext(&Msg->IO,
+ resolve_mx_records);
+ else { /* oh... via relay host */
+ if (Msg->pCurrRelay->IsIP) {
+ QueueEventContext(&Msg->IO,
+ mx_connect_ip);
+ }
+ else {
+ /* uneducated admin has chosen to
+ add DNS to the equation... */
+ QueueEventContext(&Msg->IO,
+ get_one_mx_host_ip);