-
Notifications
You must be signed in to change notification settings - Fork 0
/
SmtpServer.h
128 lines (113 loc) · 5.78 KB
/
SmtpServer.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
//---------------------------------------------------------------------------
#ifndef SmtpServerH
#define SmtpServerH
//---------------------------------------------------------------------------
#include <stdlib.h>
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <scktComp.hpp>
#include "LMTSTypes.h"
#include "Tokenizer.h"
#include "CmdStatsInfo.h"
#include "MailIdentity.h"
#include "AddressBook.h"
#include "MailHeaders.h"
//---------------------------------------------------------------------------
class PACKAGE TSmtpServer : public TComponent
{
private:
TNotifyEvent FOnServerStarted;
TNotifyEvent FOnServerStopped;
TLogNotifyEvent FOnLogEvent;
TClientNotifyEvent FOnClientConnected;
TClientNotifyEvent FOnClientDisconnected;
THostValidationEvent FOnHostValidationRequired;
TUserValidationEvent FOnSenderValidationRequired;
TUserValidationEvent FOnRecipientValidationRequired;
TMessageBeforeSaveEvent FOnMessageBeforeSave;
TMessageAfterSaveEvent FOnMessageAfterSave;
TValidateMaxRecipients FOnMaxRecipientsCheck;
TValidateMaxMsgSize FOnMaxMsgSizeCheck;
TServerSocket *FServerSocket;
TTokenizer *Tokens;
TSmtpServerState ServerState;
int FLoggingLevel;
int FMessagesHandled;
long FBytesHandled;
AnsiString *FMailDir;
AnsiString *FMailFileExt;
AnsiString *FMailFilePrefix;
AnsiString *FMyName;
bool FActive;
int FPort;
TMailIdentity *UserFrom;
TAddressBook *UsersTo;
long FCurrSize;
TMemoryStream *MailMsg;
TMailHeaders *MsgHeaders;
AnsiString *ClientName;
AnsiString *RecvData;
AnsiString *SendData;
AnsiString *Command;
AnsiString *Parm1;
AnsiString *Parm2;
TCmdStatsInfo *Statistics;
protected:
void __fastcall SetActive(bool act);
void __fastcall SetLoggingLevel(int i);
void __fastcall SetPortA(int p);
AnsiString __fastcall GetMailDir();
AnsiString __fastcall GetMyName();
void __fastcall SetMyName(AnsiString mn);
void __fastcall SetMailDir(AnsiString md);
AnsiString __fastcall GetMailFileExt();
void __fastcall SetMailFileExt(AnsiString mfe);
AnsiString __fastcall GetMailFilePrefix();
void __fastcall SetMailFilePrefix(AnsiString mfp);
void __fastcall EventClientConnect(TObject* Sender, TCustomWinSocket* Socket);
void __fastcall EventClientDisconnect(TObject* Sender, TCustomWinSocket* Socket);
void __fastcall EventClientRead(TObject* Sender, TCustomWinSocket* Socket);
void __fastcall EventClientWrite(TObject* Sender, TCustomWinSocket* Socket);
void __fastcall EventClientError(TObject* Sender, TCustomWinSocket* Socket, TErrorEvent ErrorEvent, int &ErrorCode);
void __fastcall LogEvent(const AnsiString le);
void __fastcall ProcessInput(TCustomWinSocket* Socket);
void __fastcall InitStatistics();
// bool __fastcall MsgCompleted();
bool __fastcall MsgCompleted(TMemoryStream *ms);
void __fastcall GetMailFilename(AnsiString *newname);
void __fastcall SaveFile(TMemoryStream *s, AnsiString src, AnsiString newname);
void __fastcall ResetState();
void __fastcall ResetMsg();
void __fastcall CreateMsgIdentifier(AnsiString *mid);
public:
__fastcall TSmtpServer(TComponent* Owner);
__fastcall ~TSmtpServer();
void __fastcall Start();
void __fastcall Stop();
__published:
__property bool Active = {read=FActive, write=SetActive, default=false};
__property int Port = {read=FPort, write=SetPortA, default=0};
__property int LoggingLevel = {read=FLoggingLevel, write=SetLoggingLevel, default=SMTP_LOG_CONNECTS};
__property int MessagesHandled = {read=FMessagesHandled};
__property long BytesHandled = {read=FBytesHandled};
__property AnsiString MyName = {read=GetMyName, write=SetMyName};
__property AnsiString MailDir = {read=GetMailDir, write=SetMailDir};
__property AnsiString MailFileExt = {read=GetMailFileExt, write=SetMailFileExt};
__property AnsiString MailFilePrefix = {read=GetMailFilePrefix, write=SetMailFilePrefix};
__property TClientNotifyEvent OnClientConnected = {read=FOnClientConnected, write=FOnClientConnected};
__property TClientNotifyEvent OnClientDisconnected = {read=FOnClientDisconnected, write=FOnClientDisconnected};
__property THostValidationEvent OnHostValidationRequired = {read=FOnHostValidationRequired, write=FOnHostValidationRequired};
__property TUserValidationEvent OnSenderValidationRequired = {read=FOnSenderValidationRequired, write=FOnSenderValidationRequired};
__property TUserValidationEvent OnRecipientValidationRequired = {read=FOnRecipientValidationRequired, write=FOnRecipientValidationRequired};
__property TMessageBeforeSaveEvent OnMessageBeforeSave = {read=FOnMessageBeforeSave, write=FOnMessageBeforeSave};
__property TMessageAfterSaveEvent OnMessageAfterSave = {read=FOnMessageAfterSave, write=FOnMessageAfterSave};
__property TLogNotifyEvent OnLogEvent = {read=FOnLogEvent, write=FOnLogEvent};
__property TNotifyEvent OnServerStarted = {read=FOnServerStarted, write=FOnServerStarted};
__property TNotifyEvent OnServerStopped = {read=FOnServerStopped, write=FOnServerStopped};
__property TValidateMaxRecipients OnMaxRecipientsCheck = {read=FOnMaxRecipientsCheck, write=FOnMaxRecipientsCheck};
__property TValidateMaxMsgSize OnMaxMsgSizeCheck = {read=FOnMaxMsgSizeCheck, write=FOnMaxMsgSizeCheck};
};
//---------------------------------------------------------------------------
#endif