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