Changes that are broken
This commit is contained in:
1 parent
c9cdc822a2
commit
0a4d17e6e6
9 files changed
+110
-60
No files matched your search
+5
-49
@@ -19,61 +19,23 @@
|
||||
# include "__SMTP_RSET.h"
|
||||
# include "__SMTP_VRFY.h"
|
||||
# include "INotify.h"
|
||||
# include "Log.h"
|
||||
# include "SendMail.h"
|
||||
|
||||
namespace mail {
|
||||
|
||||
class SMTPServer : public core::TCPServer, public core::INotify {
|
||||
|
||||
public:
|
||||
SMTPServer(core::EPoll &ePoll, std::string hostName, MailFileSystem &mailFileSystem, core::IPAddress ipAddress)
|
||||
: core::TCPServer(ePoll, ipAddress, " ", 1, "SMTP Server"), core::INotify(ePoll), ePoll(ePoll), hostName(hostName), mailFileSystem(mailFileSystem) {
|
||||
commands.add(_smtp_auth, "AUTH");
|
||||
commands.add(_smtp_data, "DATA");
|
||||
commands.add(_smtp_ehlo, "EHLO");
|
||||
commands.add(_smtp_helo, "HELO");
|
||||
commands.add(_smtp_mail, "MAIL");
|
||||
commands.add(_smtp_noop, "NOOP");
|
||||
commands.add(_smtp_quit, "QUIT");
|
||||
commands.add(_smtp_rcpt, "RCPT");
|
||||
commands.add(_smtp_rset, "RSET");
|
||||
commands.add(_smtp_vrfy, "VRFY");
|
||||
processExisting();
|
||||
wd = addWatch(mailFileSystem.getQueuePath());
|
||||
}
|
||||
SMTPServer(core::EPoll &ePoll, std::string hostName, MailFileSystem &mailFileSystem, core::IPAddress ipAddress);
|
||||
|
||||
MailFileSystem &mailFileSystem;
|
||||
std::string hostName;
|
||||
core::EPoll &ePoll;
|
||||
|
||||
SMTPSession * getSocketAccept(core::EPoll &ePoll) override {
|
||||
return new SMTPSession(ePoll, *this);
|
||||
}
|
||||
|
||||
void sessionErrorHandler(std::string errorString, std::stringstream &out) {
|
||||
out << "252 " << errorString << CRLF;
|
||||
}
|
||||
SMTPSession * getSocketAccept(core::EPoll &ePoll) override;
|
||||
void sessionErrorHandler(std::string errorString, std::stringstream &out);
|
||||
|
||||
protected:
|
||||
void inCreate(coreutils::ZString &name) {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_2) << "inCreate; [" << name << "]";
|
||||
name.split("|");
|
||||
if(name.getList().size() > 1) {
|
||||
bool exists = mailFileSystem.ifMailBoxExists(name[1]);
|
||||
coreutils::MString path;
|
||||
path << mailFileSystem.getMailBoxPath(name[1]) << "/Inbox/" << name[0];
|
||||
coreutils::MString from;
|
||||
from << mailFileSystem.getQueuePath() << "/" << name;
|
||||
if(exists) {
|
||||
int rc = link(from.c_str(), path.c_str());
|
||||
rc = unlink(from.c_str());
|
||||
coreutils::Log(coreutils::LOG_INFO) << "Message " << name[0] << " delivered to recipient " << name[1] << ".";
|
||||
} else {
|
||||
mailQueue.emplace_back(SendMail(ePoll, name[1].str(), name[1].str(), from.str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
void inCreate(coreutils::ZString &name);
|
||||
|
||||
private:
|
||||
__SMTP_AUTH _smtp_auth;
|
||||
@@ -89,13 +51,7 @@ namespace mail {
|
||||
int wd;
|
||||
std::vector<SendMail> mailQueue;
|
||||
|
||||
void processExisting() {
|
||||
for (const auto & entry : std::filesystem::directory_iterator(mailFileSystem.getQueuePath().str())) {
|
||||
std::string temp(entry.path().filename().string());
|
||||
coreutils::ZString temp2(temp);
|
||||
inCreate(temp2);
|
||||
}
|
||||
}
|
||||
void processExisting();
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user