-
Notifications
You must be signed in to change notification settings - Fork 0
/
SMTPUtils.h
133 lines (117 loc) · 5.28 KB
/
SMTPUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* XMail by Davide Libenzi (Intranet and Internet mail server)
* Copyright (C) 1999,..,2010 Davide Libenzi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Davide Libenzi <[email protected]>
*
*/
#ifndef _SMTPUTILS_H
#define _SMTPUTILS_H
#define INVALID_MXS_HANDLE ((MXS_HANDLE) 0)
#define INVALID_SMTPCH_HANDLE ((SMTPCH_HANDLE) 0)
#define SMTP_FATAL_ERROR 999
#define RECEIVED_TYPE_STD 0
#define RECEIVED_TYPE_VERBOSE 1
#define RECEIVED_TYPE_STRICT 2
#define RECEIVED_TYPE_AUTHSTD 3
#define RECEIVED_TYPE_AUTHVERBOSE 4
#define SMTP_ERROR_VARNAME "SMTP-Error"
#define DEFAULT_SMTP_ERR "417 Temporary delivery error"
#define SMTP_SERVER_VARNAME "SMTP-Server"
#define SMTP_GWF_USE_TLS (1 << 0)
#define SMTP_GWF_FORCE_TLS (1 << 1)
typedef struct MXS_HANDLE_struct {
} *MXS_HANDLE;
typedef struct SMTPCH_HANDLE_struct {
} *SMTPCH_HANDLE;
struct SMTPError {
char *pszServer;
int iSTMPResponse;
char *pszSTMPResponse;
};
struct SMTPGateway {
char *pszHost;
char *pszIFace;
unsigned long ulFlags;
};
enum SmtpMsgInfo {
smsgiClientDomain = 0,
smsgiClientAddr,
smsgiServerDomain,
smsgiServerAddr,
smsgiTime,
smsgiSeverName,
smsgiMax
};
enum SpoolMsgInfo {
smiClientAddr,
smiServerAddr,
smiTime,
smiMax
};
SMTPGateway **USmtpMakeGateways(char const * const *ppszGwHosts, char const **ppszOptions);
void USmtpFreeGateways(SMTPGateway **ppGws);
SMTPGateway **USmtpGetCfgGateways(SVRCFG_HANDLE hSvrConfig, char const * const *ppszGwHosts,
char const *pszOptions);
SMTPGateway **USmtpGetFwdGateways(SVRCFG_HANDLE hSvrConfig, char const *pszDomain);
int USmtpGetGateway(SVRCFG_HANDLE hSvrConfig, char const *pszDomain, char *pszGateway,
int iSize);
int USmtpAddGateway(char const *pszDomain, char const *pszGateway);
int USmtpRemoveGateway(char const *pszDomain);
int USmtpIsAllowedRelay(const SYS_INET_ADDR & PeerInfo, SVRCFG_HANDLE hSvrConfig);
char **USmtpGetPathStrings(char const *pszMailCmd);
int USmtpSplitEmailAddr(char const *pszAddr, char *pszUser, char *pszDomain);
int USmtpCheckAddressPart(char const *pszName);
int USmtpCheckDomainPart(char const *pszName);
int USmtpCheckAddress(char const *pszAddress);
int USmtpInitError(SMTPError *pSMTPE);
int USmtpSetError(SMTPError *pSMTPE, int iSTMPResponse, char const *pszSTMPResponse,
char const *pszServer);
bool USmtpIsFatalError(SMTPError const *pSMTPE);
char const *USmtpGetErrorMessage(SMTPError const *pSMTPE);
int USmtpCleanupError(SMTPError *pSMTPE);
char *USmtpGetSMTPError(SMTPError *pSMTPE, char *pszError, size_t sMaxError);
char *USmtpGetSMTPRmtMsgID(char const *pszAckDATA, char *pszRmtMsgID, ssize_t sMaxMsg);
char const *USmtpGetErrorServer(SMTPError const *pSMTPE);
SMTPCH_HANDLE USmtpCreateChannel(SMTPGateway const *pGw, char const *pszDomain,
SMTPError *pSMTPE = NULL);
int USmtpCloseChannel(SMTPCH_HANDLE hSmtpCh, int iHardClose = 0, SMTPError *pSMTPE = NULL);
int USmtpChannelReset(SMTPCH_HANDLE hSmtpCh, SMTPError *pSMTPE = NULL);
int USmtpSendMail(SMTPCH_HANDLE hSmtpCh, char const *pszFrom, char const *pszRcpt,
FileSection const *pFS, SMTPError *pSMTPE = NULL);
int USmtpSendMail(SMTPGateway const *pGw, char const *pszDomain, char const *pszFrom,
char const *pszRcpt, FileSection const *pFS, SMTPError *pSMTPE = NULL);
int USmtpMailRmtDeliver(SVRCFG_HANDLE hSvrConfig, char const *pszServer, char const *pszDomain,
char const *pszFrom, char const *pszRcpt, FileSection const *pFS,
SMTPError *pSMTPE = NULL);
char *USmtpBuildRcptPath(char const *const *ppszRcptTo, SVRCFG_HANDLE hSvrConfig);
SMTPGateway **USmtpGetMailExchangers(SVRCFG_HANDLE hSvrConfig, char const *pszDomain);
int USmtpCheckMailDomain(SVRCFG_HANDLE hSvrConfig, char const *pszDomain);
MXS_HANDLE USmtpGetMXFirst(SVRCFG_HANDLE hSvrConfig, char const *pszDomain, char *pszMXHost);
int USmtpGetMXNext(MXS_HANDLE hMXSHandle, char *pszMXHost);
void USmtpMXSClose(MXS_HANDLE hMXSHandle);
int USmtpDnsMapsContained(SYS_INET_ADDR const &PeerInfo, char const *pszMapsServer);
int USmtpSpammerCheck(const SYS_INET_ADDR & PeerInfo, char *&pszInfo);
int USmtpSpamAddressCheck(char const *pszAddress);
int USmtpAddMessageInfo(FILE *pMsgFile, char const *pszClientDomain,
SYS_INET_ADDR const &PeerInfo, char const *pszServerDomain,
SYS_INET_ADDR const &SockInfo, char const *pszSmtpServerLogo);
int USmtpWriteInfoLine(FILE *pSpoolFile, char const *pszClientAddr,
char const *pszServerAddr, char const *pszTime);
char *USmtpGetReceived(int iType, char const *pszAuth, char const *const *ppszMsgInfo,
char const *pszMailFrom, char const *pszRcptTo, char const *pszMessageID);
#endif