Back to index

citadel  8.12
Classes | Defines | Typedefs | Enumerations | Functions | Variables
smtp_clienthandlers.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _stmp_out_msg

Defines

#define F_RELAY   (1<<0) /* we have a Relay host configuration */
#define F_HAVE_FALLBACK   (1<<1) /* we have a fallback host configuration */
#define F_FALLBACK   (1<<2)
#define F_HAVE_MX   (1<<3) /* we have a list of mx records to go through.*/
#define F_DIRECT   (1<<4) /* no mx record found, trying direct connect. */
#define QID   ((SmtpOutMsg*)IO->Data)->MyQItem->MessageID
#define N   ((SmtpOutMsg*)IO->Data)->n
#define DBGLOG(LEVEL)   if ((LEVEL != LOG_DEBUG) || (SMTPClientDebugEnabled != 0))
#define EVS_syslog(LEVEL, FORMAT,...)
#define EVSM_syslog(LEVEL, FORMAT)
#define EVNCS_syslog(LEVEL, FORMAT,...)
#define EVNCSM_syslog(LEVEL, FORMAT)
#define SMTPC_syslog(LEVEL, FORMAT,...)
#define SMTPCM_syslog(LEVEL, FORMAT)

Typedefs

typedef enum _eSMTP_C_States eSMTP_C_States
typedef struct _stmp_out_msg SmtpOutMsg
typedef eNextState(* SMTPReadHandler )(SmtpOutMsg *Msg)
typedef eNextState(* SMTPSendHandler )(SmtpOutMsg *Msg)

Enumerations

enum  _eSMTP_C_States {
  eConnectMX, eEHLO, eHELO, eSMTPAuth,
  eFROM, eRCPT, eDATA, eDATABody,
  eDATATerminateBody, eQUIT, eMaxSMTPC
}

Functions

int smtp_resolve_recipients (SmtpOutMsg *SendMsg)

Variables

SMTPReadHandler ReadHandlers [eMaxSMTPC]
SMTPSendHandler SendHandlers [eMaxSMTPC]
const ConstStr ReadErrors [eMaxSMTPC+1]
const double SMTP_C_ReadTimeouts [eMaxSMTPC]
const double SMTP_C_SendTimeouts [eMaxSMTPC]
const double SMTP_C_ConnTimeout
int SMTPClientDebugEnabled

Class Documentation

struct _stmp_out_msg

Definition at line 35 of file smtp_clienthandlers.h.

Collaboration diagram for _stmp_out_msg:
Class Members
struct ares_mx_reply * AllMX
struct ares_mx_reply * CurrMX
long CXFlags
const char * envelope_from
long Flags
DNSQueryParts HostLookup
int IDestructQueItem
int iMX
AsyncIO IO
const char * LookupHostname
int LookupWhich
char mailfrom
StrBuf * msgtext
const char * mx_host
const char * mx_port
DNSQueryParts MxLookup
MailQEntry * MyQEntry
OneQueItem * MyQItem
long n
char name
int nMX
char node
int nRemain
struct hostent * OneMX
ParsedURL * pCurrRelay
char ** pIP
StrBuf * QMsgData
ParsedURL * Relay
eSMTP_C_States State
char user

Define Documentation

#define DBGLOG (   LEVEL)    if ((LEVEL != LOG_DEBUG) || (SMTPClientDebugEnabled != 0))

Definition at line 96 of file smtp_clienthandlers.h.

#define EVNCS_syslog (   LEVEL,
  FORMAT,
  ... 
)
Value:
DBGLOG(LEVEL) syslog(LEVEL, "SMTPC:IO[%ld]S[%ld][%ld] " FORMAT, \
              IO->ID, QID, N, __VA_ARGS__)

Definition at line 108 of file smtp_clienthandlers.h.

#define EVNCSM_syslog (   LEVEL,
  FORMAT 
)
Value:
DBGLOG(LEVEL) syslog(LEVEL, "SMTPC:IO[%ld]S[%ld][%ld] " FORMAT, \
              IO->ID, QID, N)

Definition at line 112 of file smtp_clienthandlers.h.

#define EVS_syslog (   LEVEL,
  FORMAT,
  ... 
)
Value:
DBGLOG(LEVEL) syslog(LEVEL,          \
              "SMTPC:IO[%ld]CC[%d]S[%ld][%ld] " FORMAT, \
              IO->ID, CCID, QID, N, __VA_ARGS__)

Definition at line 98 of file smtp_clienthandlers.h.

#define EVSM_syslog (   LEVEL,
  FORMAT 
)
Value:
DBGLOG(LEVEL) syslog(LEVEL, \
              "SMTPC:IO[%ld]CC[%d]S[%ld][%ld] " FORMAT, \
              IO->ID, CCID, QID, N)

Definition at line 103 of file smtp_clienthandlers.h.

#define F_DIRECT   (1<<4) /* no mx record found, trying direct connect. */

Definition at line 88 of file smtp_clienthandlers.h.

#define F_FALLBACK   (1<<2)

Definition at line 86 of file smtp_clienthandlers.h.

#define F_HAVE_FALLBACK   (1<<1) /* we have a fallback host configuration */

Definition at line 85 of file smtp_clienthandlers.h.

#define F_HAVE_MX   (1<<3) /* we have a list of mx records to go through.*/

Definition at line 87 of file smtp_clienthandlers.h.

#define F_RELAY   (1<<0) /* we have a Relay host configuration */

Definition at line 84 of file smtp_clienthandlers.h.

#define N   ((SmtpOutMsg*)IO->Data)->n

Definition at line 95 of file smtp_clienthandlers.h.

#define QID   ((SmtpOutMsg*)IO->Data)->MyQItem->MessageID

Definition at line 94 of file smtp_clienthandlers.h.

#define SMTPC_syslog (   LEVEL,
  FORMAT,
  ... 
)
Value:
DBGLOG(LEVEL) syslog(LEVEL,          \
                          "SMTPCQ: " FORMAT,       \
                          __VA_ARGS__)

Definition at line 116 of file smtp_clienthandlers.h.

#define SMTPCM_syslog (   LEVEL,
  FORMAT 
)
Value:
DBGLOG(LEVEL) syslog(LEVEL,        \
                          "SMTPCQ: " FORMAT)

Definition at line 121 of file smtp_clienthandlers.h.


Typedef Documentation

typedef struct _stmp_out_msg SmtpOutMsg

Definition at line 74 of file smtp_clienthandlers.h.

Definition at line 75 of file smtp_clienthandlers.h.


Enumeration Type Documentation

Enumerator:
eConnectMX 
eEHLO 
eHELO 
eSMTPAuth 
eFROM 
eRCPT 
eDATA 
eDATABody 
eDATATerminateBody 
eQUIT 
eMaxSMTPC 

Definition at line 20 of file smtp_clienthandlers.h.


Function Documentation

int smtp_resolve_recipients ( SmtpOutMsg SendMsg)

Definition at line 471 of file smtp_clienthandlers.c.

{
       AsyncIO *IO = &Msg->IO;
       const char *ptr;
       char buf[1024];
       int scan_done;
       int lp, rp;
       int i;

       EVNCS_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);

       if ((Msg==NULL) ||
           (Msg->MyQEntry == NULL) ||
           (StrLength(Msg->MyQEntry->Recipient) == 0)) {
              return 0;
       }

       /* Parse out the host portion of the recipient address */
       process_rfc822_addr(ChrPtr(Msg->MyQEntry->Recipient),
                         Msg->user,
                         Msg->node,
                         Msg->name);

       EVNCS_syslog(LOG_DEBUG,
                   "Attempting delivery to <%s> @ <%s> (%s)\n",
                   Msg->user,
                   Msg->node,
                   Msg->name);

       /* If no envelope_from is supplied, extract one from the message */
       Msg->envelope_from = ChrPtr(Msg->MyQItem->EnvelopeFrom);
       if ( (Msg->envelope_from == NULL) ||
            (IsEmptyStr(Msg->envelope_from)) ) {
              Msg->mailfrom[0] = '\0';
              scan_done = 0;
              ptr = ChrPtr(Msg->msgtext);
              do {
                     if (ptr = cmemreadline(ptr, buf, sizeof buf), *ptr == 0)
                     {
                            scan_done = 1;
                     }
                     if (!strncasecmp(buf, "From:", 5))
                     {
                            safestrncpy(Msg->mailfrom,
                                       &buf[5],
                                       sizeof Msg->mailfrom);

                            striplt(Msg->mailfrom);
                            for (i=0; Msg->mailfrom[i]; ++i) {
                                   if (!isprint(Msg->mailfrom[i]))
                                   {
                                          strcpy(&Msg->mailfrom[i],
                                                 &Msg->mailfrom[i+1]);
                                          i=0;
                                   }
                            }

                            /* Strip out parenthesized names */
                            lp = (-1);
                            rp = (-1);
                            for (i=0;
                                 !IsEmptyStr(Msg->mailfrom + i);
                                 ++i)
                            {
                                   if (Msg->mailfrom[i] == '(') lp = i;
                                   if (Msg->mailfrom[i] == ')') rp = i;
                            }
                            if ((lp>0)&&(rp>lp))
                            {
                                   strcpy(&Msg->mailfrom[lp-1],
                                          &Msg->mailfrom[rp+1]);
                            }

                            /* Prefer brokketized names */
                            lp = (-1);
                            rp = (-1);
                            for (i=0;
                                 !IsEmptyStr(Msg->mailfrom + i);
                                 ++i)
                            {
                                   if (Msg->mailfrom[i] == '<') lp = i;
                                   if (Msg->mailfrom[i] == '>') rp = i;
                            }
                            if ( (lp>=0) && (rp>lp) ) {
                                   Msg->mailfrom[rp] = 0;
                                   memmove(Msg->mailfrom,
                                          &Msg->mailfrom[lp + 1],
                                          rp - lp);
                            }

                            scan_done = 1;
                     }
              } while (scan_done == 0);
              if (IsEmptyStr(Msg->mailfrom))
                     strcpy(Msg->mailfrom, "someone@somewhere.org");

              stripallbut(Msg->mailfrom, '<', '>');
              Msg->envelope_from = Msg->mailfrom;
       }

       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const ConstStr ReadErrors[eMaxSMTPC+1]

Definition at line 79 of file smtp_clienthandlers.h.

Definition at line 77 of file smtp_clienthandlers.h.

Definition at line 78 of file smtp_clienthandlers.h.

const double SMTP_C_ConnTimeout

Definition at line 82 of file smtp_clienthandlers.h.

Definition at line 80 of file smtp_clienthandlers.h.

Definition at line 81 of file smtp_clienthandlers.h.

Definition at line 93 of file serv_smtpeventclient.c.