3 * Copyright (c) 1998-2012 by the citadel.org team
5 * This program is open source software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 typedef enum _eSMTP_C_States {
37 typedef struct _stmp_out_msg {
48 struct ares_mx_reply *AllMX;
49 struct ares_mx_reply *CurrMX;
52 const char *LookupHostname;
56 DNSQueryParts MxLookup;
57 DNSQueryParts HostLookup;
58 struct hostent *OneMX;
62 ParsedURL *pCurrRelay;
66 const char *envelope_from;
78 typedef eNextState (*SMTPReadHandler)(SmtpOutMsg *Msg);
79 typedef eNextState (*SMTPSendHandler)(SmtpOutMsg *Msg);
81 SMTPReadHandler ReadHandlers[eMaxSMTPC];
82 SMTPSendHandler SendHandlers[eMaxSMTPC];
83 const ConstStr ReadErrors[eMaxSMTPC+1];
84 const double SMTP_C_ReadTimeouts[eMaxSMTPC];
85 const double SMTP_C_SendTimeouts[eMaxSMTPC];
86 const double SMTP_C_ConnTimeout;
88 #define F_RELAY (1<<0) /* we have a Relay host configuration */
89 #define F_HAVE_FALLBACK (1<<1) /* we have a fallback host configuration */
90 #define F_FALLBACK (1<<2)
91 #define F_HAVE_MX (1<<3) /* we have a list of mx records to go through.*/
92 #define F_DIRECT (1<<4) /* no mx record found, trying direct connect. */
94 extern int SMTPClientDebugEnabled;
96 int smtp_resolve_recipients(SmtpOutMsg *SendMsg);
98 #define QID ((SmtpOutMsg*)IO->Data)->MyQItem->MessageID
99 #define N ((SmtpOutMsg*)IO->Data)->n
100 #define DBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (SMTPClientDebugEnabled != 0))
102 #define EVS_syslog(LEVEL, FORMAT, ...) \
103 DBGLOG(LEVEL) syslog(LEVEL, \
104 "SMTPC:%s[%ld]CC[%d]S[%ld][%ld] " FORMAT, \
105 IOSTR, IO->ID, CCID, QID, N, __VA_ARGS__)
107 #define EVSM_syslog(LEVEL, FORMAT) \
108 DBGLOG(LEVEL) syslog(LEVEL, \
109 "SMTPC:%s[%ld]CC[%d]S[%ld][%ld] " FORMAT, \
110 IOSTR, IO->ID, CCID, QID, N)
112 #define EVNCS_syslog(LEVEL, FORMAT, ...) \
113 DBGLOG(LEVEL) syslog(LEVEL, "SMTPC:%s[%ld]S[%ld][%ld] " FORMAT, \
114 IOSTR, IO->ID, QID, N, __VA_ARGS__)
116 #define EVNCSM_syslog(LEVEL, FORMAT) \
117 DBGLOG(LEVEL) syslog(LEVEL, "SMTPC:%s[%ld]S[%ld][%ld] " FORMAT, \
118 IOSTR, IO->ID, QID, N)
120 #define SMTPC_syslog(LEVEL, FORMAT, ...) \
121 DBGLOG(LEVEL) syslog(LEVEL, \
125 #define SMTPCM_syslog(LEVEL, FORMAT) \
126 DBGLOG(LEVEL) syslog(LEVEL, \
131 typedef enum __smtpstate {
146 void SetSMTPState(AsyncIO *IO, smtpstate State);