Back to index

citadel  8.12
smtp_clienthandlers.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * Copyright (c) 1998-2012 by the citadel.org team
00004  *
00005  *  This program is open source software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 3 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 typedef enum _eSMTP_C_States {
00021        eConnectMX,
00022        eEHLO,
00023        eHELO,
00024        eSMTPAuth,
00025        eFROM,
00026        eRCPT,
00027        eDATA,
00028        eDATABody,
00029        eDATATerminateBody,
00030        eQUIT,
00031        eMaxSMTPC
00032 } eSMTP_C_States;
00033 
00034 
00035 typedef struct _stmp_out_msg {
00036        MailQEntry *MyQEntry;
00037        OneQueItem *MyQItem;
00038        long n;
00039        AsyncIO IO;
00040        long CXFlags;
00041        int IDestructQueItem;
00042        int nRemain;
00043 
00044        eSMTP_C_States State;
00045 
00046        struct ares_mx_reply *AllMX;
00047        struct ares_mx_reply *CurrMX;
00048        const char *mx_port;
00049        const char *mx_host;
00050        const char *LookupHostname;
00051        int iMX, nMX;
00052        int LookupWhich;
00053 
00054        DNSQueryParts MxLookup;
00055        DNSQueryParts HostLookup;
00056        struct hostent *OneMX;
00057        char **pIP;
00058 
00059        ParsedURL *Relay;
00060        ParsedURL *pCurrRelay;
00061        StrBuf *msgtext;
00062        StrBuf *QMsgData;
00063        const char *envelope_from;
00064 
00065        char user[1024];
00066        char node[1024];
00067        char name[1024];
00068        char mailfrom[1024];
00069 
00070        long Flags;
00071 } SmtpOutMsg;
00072 
00073 
00074 typedef eNextState (*SMTPReadHandler)(SmtpOutMsg *Msg);
00075 typedef eNextState (*SMTPSendHandler)(SmtpOutMsg *Msg);
00076 
00077 SMTPReadHandler ReadHandlers[eMaxSMTPC];
00078 SMTPSendHandler SendHandlers[eMaxSMTPC];
00079 const ConstStr ReadErrors[eMaxSMTPC+1];
00080 const double SMTP_C_ReadTimeouts[eMaxSMTPC];
00081 const double SMTP_C_SendTimeouts[eMaxSMTPC];
00082 const double SMTP_C_ConnTimeout;
00083 
00084 #define F_RELAY          (1<<0) /* we have a Relay    host configuration */
00085 #define F_HAVE_FALLBACK  (1<<1) /* we have a fallback host configuration */
00086 #define F_FALLBACK       (1<<2)
00087 #define F_HAVE_MX        (1<<3) /* we have a list of mx records to go through.*/
00088 #define F_DIRECT         (1<<4) /* no mx record found, trying direct connect. */
00089 
00090 extern int SMTPClientDebugEnabled;
00091 
00092 int smtp_resolve_recipients(SmtpOutMsg *SendMsg);
00093 
00094 #define QID ((SmtpOutMsg*)IO->Data)->MyQItem->MessageID
00095 #define N ((SmtpOutMsg*)IO->Data)->n
00096 #define DBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (SMTPClientDebugEnabled != 0))
00097 
00098 #define EVS_syslog(LEVEL, FORMAT, ...) \
00099        DBGLOG(LEVEL) syslog(LEVEL,          \
00100               "SMTPC:IO[%ld]CC[%d]S[%ld][%ld] " FORMAT, \
00101               IO->ID, CCID, QID, N, __VA_ARGS__)
00102 
00103 #define EVSM_syslog(LEVEL, FORMAT) \
00104        DBGLOG(LEVEL) syslog(LEVEL, \
00105               "SMTPC:IO[%ld]CC[%d]S[%ld][%ld] " FORMAT, \
00106               IO->ID, CCID, QID, N)
00107 
00108 #define EVNCS_syslog(LEVEL, FORMAT, ...) \
00109        DBGLOG(LEVEL) syslog(LEVEL, "SMTPC:IO[%ld]S[%ld][%ld] " FORMAT, \
00110               IO->ID, QID, N, __VA_ARGS__)
00111 
00112 #define EVNCSM_syslog(LEVEL, FORMAT) \
00113        DBGLOG(LEVEL) syslog(LEVEL, "SMTPC:IO[%ld]S[%ld][%ld] " FORMAT, \
00114               IO->ID, QID, N)
00115 
00116 #define SMTPC_syslog(LEVEL, FORMAT, ...)    \
00117        DBGLOG(LEVEL) syslog(LEVEL,          \
00118                           "SMTPCQ: " FORMAT,       \
00119                           __VA_ARGS__)
00120 
00121 #define SMTPCM_syslog(LEVEL, FORMAT)             \
00122        DBGLOG(LEVEL) syslog(LEVEL,        \
00123                           "SMTPCQ: " FORMAT)