Libev / libc-ares Migration
[citadel.git] / citadel / modules / smtp / smtpqueue.h
1 /*****************************************************************************/
2 /*               SMTP CLIENT (Queue Management) STUFF                        */
3 /*****************************************************************************/
4
5 #define MaxAttempts 15
6 typedef struct _delivery_attempt {
7         time_t when;
8         time_t retry;
9 }DeliveryAttempt;
10
11 typedef struct _mailq_entry {
12         DeliveryAttempt Attempts[MaxAttempts];
13         int nAttempts;
14         StrBuf *Recipient;
15         StrBuf *StatusMessage;
16         int Status;
17         /**<
18          * 0 = No delivery has yet been attempted
19          * 2 = Delivery was successful
20          * 4 = A transient error was experienced ... try again later
21          * 5 = Delivery to this address failed permanently.  The error message
22          *     should be placed in the fourth field so that a bounce message may
23          *     be generated.
24          */
25
26         int n;
27         int Active;
28 }MailQEntry;
29
30 typedef struct queueitem {
31         long MessageID;
32         long QueMsgID;
33         long Submitted;
34         int FailNow;
35         HashList *MailQEntries;
36         MailQEntry *Current; /* copy of the currently parsed item in the MailQEntries list; if null add a new one. */
37         DeliveryAttempt LastAttempt;
38         long ActiveDeliveries;
39         StrBuf *EnvelopeFrom;
40         StrBuf *BounceTo;
41 } OneQueItem;
42 typedef void (*QItemHandler)(OneQueItem *Item, StrBuf *Line, const char **Pos);
43
44 int DecreaseQReference(OneQueItem *MyQItem);
45 void RemoveQItem(OneQueItem *MyQItem);
46 int CountActiveQueueEntries(OneQueItem *MyQItem);
47 StrBuf *SerializeQueueItem(OneQueItem *MyQItem);
48
49 void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt);