+ if (Msg->MyQEntry->Status == 2) {
+ SetSMTPState(IO, eSTMPfinished);
+ Status = "Delivery successful.";
+ }
+ else if (Msg->MyQEntry->Status == 5) {
+ SetSMTPState(IO, eSMTPFailTotal);
+ Status = "Delivery failed permanently; giving up.";
+ }
+ else {
+ SetSMTPState(IO, eSMTPFailTemporary);
+ Status = "Delivery failed temporarily; will retry later.";
+ }
+
+ EVS_syslog(LOG_INFO,
+ "%s Time[%fs] Recipient <%s> @ <%s> (%s) Status message: %s\n",
+ Status,
+ Msg->IO.Now - Msg->IO.StartIO,
+ Msg->user,
+ Msg->node,
+ Msg->name,
+ ChrPtr(Msg->MyQEntry->StatusMessage));
+
+
+ Msg->IDestructQueItem = DecreaseQReference(Msg->MyQItem);
+
+ Msg->nRemain = CountActiveQueueEntries(Msg->MyQItem, 0);
+
+ if (Msg->MyQEntry->Active &&
+ !Msg->MyQEntry->StillActive &&
+ CheckQEntryIsBounce(Msg->MyQEntry))
+ {
+ /* are we casue for a bounce mail? */
+ Msg->MyQItem->SendBounceMail |= (1<<Msg->MyQEntry->Status);
+ }
+
+ if ((Msg->nRemain > 0) || Msg->IDestructQueItem)
+ Msg->QMsgData = SerializeQueueItem(Msg->MyQItem);
+ else
+ Msg->QMsgData = NULL;
+
+ /*
+ * Uncompleted delivery instructions remain, so delete the old
+ * instructions and replace with the updated ones.
+ */
+ EVS_syslog(LOG_DEBUG, "%ld", Msg->MyQItem->QueMsgID);
+ CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, &Msg->MyQItem->QueMsgID, 1, "");
+ Msg->MyQItem->QueMsgID = -1;
+
+ if (Msg->IDestructQueItem)
+ smtpq_do_bounce(Msg->MyQItem, Msg->msgtext, Msg->pCurrRelay);
+
+ if (Msg->nRemain > 0)