return 0;
}
-int CountActiveQueueEntries(OneQueItem *MyQItem)
+int CountActiveQueueEntries(OneQueItem *MyQItem, int before)
{
HashPos *It;
long len;
It = GetNewHashPos(MyQItem->MailQEntries, 0);
while (GetNextHashPos(MyQItem->MailQEntries, It, &len, &Key, &vQE))
{
+ int Active;
MailQEntry *ThisItem = vQE;
if (CheckQEntryActive(ThisItem))
{
ActiveDeliveries++;
- ThisItem->Active = 1;
+ Active = 1;
}
else
- ThisItem->Active = 0;
+ Active = 0;
+ if (before)
+ ThisItem->Active = Active;
+ else
+ ThisItem->StillActive = Active;
}
DeleteHashPos(&It);
return ActiveDeliveries;
* instructions for "5" codes (permanent fatal errors) and produce/deliver
* a "bounce" message (delivery status notification).
*/
-void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt)
+void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt, ParsedURL *Relay)
{
static int seq = 0;
{
++num_bounces;
+ StrBufAppendBufPlain(Msg, HKEY(" "), 0);
StrBufAppendBuf(Msg, ThisItem->Recipient, 0);
StrBufAppendBufPlain(Msg, HKEY(": "), 0);
StrBufAppendBuf(Msg, ThisItem->StatusMessage, 0);
return;
}
+ if ((StrLength(MyQItem->SenderRoom) == 0) && MyQItem->HaveRelay) {
+ /* one message that relaying is broken is enough; no extra room error message. */
+ StrBuf *RelayDetails = NewStrBuf();
+
+ StrBufPrintf(RelayDetails,
+ "Relaying via %s failed permanently. \n Reason:\n%s\n Revalidate your relay configuration.",
+ ChrPtr(Relay->URL),
+ ChrPtr(Msg));
+ CtdlAideMessage(ChrPtr(RelayDetails), "Relaying Failed");
+ FreeStrBuf(&RelayDetails);
+ }
+
boundary = NewStrBufPlain(HKEY("=_Citadel_Multipart_"));
StrBufAppendPrintf(boundary,
"%s_%04x%04x",
{
char mxbuf[SIZ];
ParsedURL **Url = &MyQItem->URL;
- nRelays = get_hosts(mxbuf, "smarthost");
+ nRelays = get_hosts(mxbuf, "fallbackhost");
if (nRelays > 0) {
StrBuf *All;
StrBuf *One;
ChrPtr(One));
}
else {
- ///if (!Url->IsIP)) // todo dupe me fork ipv6
- Url = &(*Url)->Next;
+ (*Url)->IsRelay = 1;
+ MyQItem->HaveRelay = 1;
}
}
FreeStrBuf(&All);
FreeStrBuf(&One);
}
-
- Url = &MyQItem->FallBackHost;
- nRelays = get_hosts(mxbuf, "fallbackhost");
+ nRelays = get_hosts(mxbuf, "smarthost");
if (nRelays > 0) {
StrBuf *All;
StrBuf *One;
"Failed to parse: %s\n",
ChrPtr(One));
}
- else
- Url = &(*Url)->Next;
+ else {
+ ///if (!Url->IsIP)) // todo dupe me fork ipv6
+ (*Url)->IsRelay = 1;
+ MyQItem->HaveRelay = 1;
+ }
}
FreeStrBuf(&All);
FreeStrBuf(&One);
}
+
}
It = GetNewHashPos(MyQItem->MailQEntries, 0);
DeleteHashPos(&It);
MyQItem->NotYetShutdownDeliveries =
- MyQItem->ActiveDeliveries = CountActiveQueueEntries(MyQItem);
+ MyQItem->ActiveDeliveries = CountActiveQueueEntries(MyQItem, 1);
/* failsafe against overload:
* will we exceed the limit set?
CtdlRegisterEVCleanupHook(smtp_evq_cleanup);
CtdlRegisterProtoHook(cmd_smtp, "SMTP", "SMTP utility commands");
- CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER);
+ CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER, PRIO_SEND + 10);
}
/* return our Subversion id for the Log */