From 72716e2c2fd4025b09bda22cfcb7dcb9d12792aa Mon Sep 17 00:00:00 2001 From: Pixel Date: Wed, 8 Oct 2008 13:56:21 -0700 Subject: Adding the MailHandler system for SMTP server. --- lib/MailServer.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/MailServer.cc b/lib/MailServer.cc index b34678e..d0bb165 100644 --- a/lib/MailServer.cc +++ b/lib/MailServer.cc @@ -31,7 +31,7 @@ const timeval timeout_sending = { 80, 0 }; class ProcessSMTPRequest : public Task { public: - ProcessSMTPRequest(const Socket & out) : s(out) { + ProcessSMTPRequest(const Socket & out, MailHandler * _handler) : s(out), handler(_handler) { SetBurst(); } virtual ~ProcessSMTPRequest() { @@ -47,6 +47,7 @@ class ProcessSMTPRequest : public Task { Task * c; String from; std::vector tos; + MailHandler * handler; }; static Regex single_dot("^\\.$"), dotted_line("^\\..+$"); @@ -158,7 +159,8 @@ int ProcessSMTPRequest::Do() { } } - // do something with out + if (handler) + handler->ProcessMail(out, from, tos); delete out; @@ -174,7 +176,7 @@ int ProcessSMTPRequest::Do() { } } -MailServer::MailServer(int _port, const String & _name) throw (GeneralException) : name(_name), localport(_port) { +MailServer::MailServer(MailHandler * _handler, int _port, const String & _name) throw (GeneralException) : name(_name), localport(_port), handler(_handler) { bool r; r = Listener.SetLocal("", localport); @@ -200,7 +202,7 @@ int MailServer::Do() throw (GeneralException) { try { Socket s = Listener.Accept(); s.SetNonBlock(); - new ProcessSMTPRequest(s); + new ProcessSMTPRequest(s, handler); } catch (GeneralException) { } -- cgit v1.2.3