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