improve logging output of event clients & opnional DNS lookup
[citadel.git] / citadel / modules / smtp / smtp_clienthandlers.h
1 typedef enum _eSMTP_C_States {
2         eConnectMX, 
3         eEHLO,
4         eHELO,
5         eSMTPAuth,
6         eFROM,
7         eRCPT,
8         eDATA,
9         eDATABody,
10         eDATATerminateBody,
11         eQUIT,
12         eMaxSMTPC
13 } eSMTP_C_States;
14
15
16 typedef struct _stmp_out_msg {
17         MailQEntry *MyQEntry;
18         OneQueItem *MyQItem;
19         long n;
20         AsyncIO IO;
21         long CXFlags;
22
23         eSMTP_C_States State;
24
25         struct ares_mx_reply *AllMX;
26         struct ares_mx_reply *CurrMX;
27         const char *mx_port;
28         const char *mx_host;
29         const char *LookupHostname;
30         int iMX, nMX;
31         int LookupWhich;
32
33         DNSQueryParts MxLookup;
34         DNSQueryParts HostLookup;
35         struct hostent *OneMX;
36         char **pIP;
37
38         ParsedURL *Relay;
39         ParsedURL *pCurrRelay;
40         StrBuf *msgtext;
41         const char *envelope_from;
42         char user[1024];
43         char node[1024];
44         char name[1024];
45         char mailfrom[1024];
46         long Flags;
47 } SmtpOutMsg;
48
49
50 typedef eNextState (*SMTPReadHandler)(SmtpOutMsg *Msg);
51 typedef eNextState (*SMTPSendHandler)(SmtpOutMsg *Msg);
52
53 SMTPReadHandler ReadHandlers[eMaxSMTPC];
54 SMTPSendHandler SendHandlers[eMaxSMTPC];
55 const ConstStr ReadErrors[eMaxSMTPC+1];
56 const double SMTP_C_ReadTimeouts[eMaxSMTPC];
57 const double SMTP_C_SendTimeouts[eMaxSMTPC];
58 const double SMTP_C_ConnTimeout;
59
60 #define F_RELAY          (1<<0) /* we have a Relay    host configuration */
61 #define F_HAVE_FALLBACK  (1<<1) /* we have a fallback host configuration */
62 #define F_FALLBACK       (1<<2)
63 #define F_HAVE_MX        (1<<3) /* we have a list of mx records to go through. */
64 #define F_DIRECT         (1<<4) /* no mx record found, trying direct connect. */
65
66
67 int smtp_resolve_recipients(SmtpOutMsg *SendMsg);
68
69 #define QID ((SmtpOutMsg*)IO->Data)->MyQItem->MessageID
70 #define N ((SmtpOutMsg*)IO->Data)->n
71 #define EVS_syslog(LEVEL, FORMAT, ...) syslog(LEVEL, "IO[%ld]CC[%d]S[%ld][%ld]" FORMAT, IO->ID, CCID, QID, N, __VA_ARGS__)
72 #define EVSM_syslog(LEVEL, FORMAT) syslog(LEVEL, "IO[%ld]CC[%d]S[%ld][%ld]" FORMAT, IO->ID, CCID, QID, N)
73 #define EVNCS_syslog(LEVEL, FORMAT, ...) syslog(LEVEL, "IO[%ld]S[%ld][%ld]" FORMAT, IO->ID, QID, N, __VA_ARGS__)
74 #define EVNCSM_syslog(LEVEL, FORMAT) syslog(LEVEL, "IO[%ld]S[%ld][%ld]" FORMAT, IO->ID, QID, N)