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