This thread includes now recognised builds containing new functionality. The latest RvdH inclusive release: viewtopic.php?p=252325#p252325
Mod.
----------------------------------------------------------------
Well... Not sure how this is progressing so...
Moved my personal changes forward from 5.4.2-B1964 to 5.6.5-B2367. Those of you with programming genes know how to work this file. Not a Git-Geek - did SVN back in the day, worked mostly on 'nix, thus the "diff"
Pitfalls (YES, there is...) If you assign ANY value to "Return.Value" in "Sub OnHELO(oClient)" the server WILL crash. Here, I've said it, be warned!
Code: Select all
diff -bur Z:\hMailServer-5.6.5\B2367/ScriptServer.cpp Z:\hMailServer-5.6.5\B2367.1/ScriptServer.cpp
--- Z:\hMailServer-5.6.5\B2367/ScriptServer.cpp 2016-05-24 13:12:26.000000000 +0200
+++ Z:\hMailServer-5.6.5\B2367.1/ScriptServer.cpp 2016-08-10 13:38:00.999999900 +0200
@@ -29,7 +29,8 @@
has_on_error_(false),
has_on_delivery_failed_(false),
has_on_external_account_download_(false),
- has_on_smtpdata_(false)
+ has_on_smtpdata_(false),
+ has_on_helo_(false)
{
}
@@ -97,6 +98,7 @@
has_on_delivery_failed_ = DoesFunctionExist_("OnDeliveryFailed");
has_on_external_account_download_ = DoesFunctionExist_("OnExternalAccountDownload");
has_on_smtpdata_ = DoesFunctionExist_("OnSMTPData");
+ has_on_helo_ = DoesFunctionExist_("OnHELO");
}
catch (...)
@@ -251,6 +253,12 @@
return;
break;
+ case EventOnHELO:
+ event_name_ = _T("OnHELO");
+ if (!has_on_helo_)
+ return;
+ break;
+
case EventCustom:
break;
default:
diff -bur Z:\hMailServer-5.6.5\B2367/ScriptServer.h Z:\hMailServer-5.6.5\B2367.1/ScriptServer.h
--- Z:\hMailServer-5.6.5\B2367/ScriptServer.h 2016-05-24 13:12:26.000000000 +0200
+++ Z:\hMailServer-5.6.5\B2367.1/ScriptServer.h 2016-08-10 13:02:02.999999900 +0200
@@ -28,6 +28,7 @@
EventOnExternalAccountDownload = 1011,
EventOnSMTPData = 1012,
+ EventOnHELO = 1013,
};
ScriptServer(void);
@@ -64,6 +65,7 @@
bool has_on_delivery_failed_;
bool has_on_external_account_download_;
bool has_on_smtpdata_;
+ bool has_on_helo_;
String script_contents_;
String script_extension_;
diff -bur Z:\hMailServer-5.6.5\B2367/SMTPConnection.cpp Z:\hMailServer-5.6.5\B2367.1/SMTPConnection.cpp
--- Z:\hMailServer-5.6.5\B2367/SMTPConnection.cpp 2016-05-24 13:12:26.000000000 +0200
+++ Z:\hMailServer-5.6.5\B2367.1/SMTPConnection.cpp 2016-08-10 13:30:54.999999900 +0200
@@ -1513,6 +1513,51 @@
return;
}
+ //
+ // Event OnHELO
+ //
+ if (Configuration::Instance()->GetUseScriptServer())
+ {
+ std::shared_ptr<ScriptObjectContainer> pContainer = std::shared_ptr<ScriptObjectContainer>(new ScriptObjectContainer);
+ std::shared_ptr<Result> pResult = std::shared_ptr<Result>(new Result);
+ std::shared_ptr<ClientInfo> pClientInfo = std::shared_ptr<ClientInfo>(new ClientInfo);
+
+ pClientInfo->SetIPAddress(GetIPAddressString());
+ pClientInfo->SetPort(GetLocalEndpointPort());
+ pClientInfo->SetHELO(helo_host_);
+
+ pContainer->AddObject("HMAILSERVER_CLIENT", pClientInfo, ScriptObject::OTClient);
+ pContainer->AddObject("Result", pResult, ScriptObject::OTResult);
+
+ String sEventCaller = "OnHELO(HMAILSERVER_CLIENT)";
+ ScriptServer::Instance()->FireEvent(ScriptServer::EventOnHELO, sEventCaller, pContainer);
+
+ switch (pResult->GetValue())
+ {
+ case 1:
+ {
+ String sErrorMessage = "554 Rejected";
+ EnqueueWrite_(sErrorMessage);
+ LogAwstatsMessageRejected_();
+ return;
+ }
+ case 2:
+ {
+ String sErrorMessage = "554 " + pResult->GetMessage();
+ EnqueueWrite_(sErrorMessage);
+ LogAwstatsMessageRejected_();
+ return;
+ }
+ case 3:
+ {
+ String sErrorMessage = "453 " + pResult->GetMessage();
+ EnqueueWrite_(sErrorMessage);
+ LogAwstatsMessageRejected_();
+ return;
+ }
+ }
+ }
+
SendEHLOKeywords_();
if (current_state_ == INITIAL)
@@ -1531,6 +1576,51 @@
return;
}
+ //
+ // Event OnHELO
+ //
+ if (Configuration::Instance()->GetUseScriptServer())
+ {
+ std::shared_ptr<ScriptObjectContainer> pContainer = std::shared_ptr<ScriptObjectContainer>(new ScriptObjectContainer);
+ std::shared_ptr<Result> pResult = std::shared_ptr<Result>(new Result);
+ std::shared_ptr<ClientInfo> pClientInfo = std::shared_ptr<ClientInfo>(new ClientInfo);
+
+ pClientInfo->SetIPAddress(GetIPAddressString());
+ pClientInfo->SetPort(GetLocalEndpointPort());
+ pClientInfo->SetHELO(helo_host_);
+
+ pContainer->AddObject("HMAILSERVER_CLIENT", pClientInfo, ScriptObject::OTClient);
+ pContainer->AddObject("Result", pResult, ScriptObject::OTResult);
+
+ String sEventCaller = "OnHELO(HMAILSERVER_CLIENT)";
+ ScriptServer::Instance()->FireEvent(ScriptServer::EventOnHELO, sEventCaller, pContainer);
+
+ switch (pResult->GetValue())
+ {
+ case 1:
+ {
+ String sErrorMessage = "554 Rejected";
+ EnqueueWrite_(sErrorMessage);
+ LogAwstatsMessageRejected_();
+ return;
+ }
+ case 2:
+ {
+ String sErrorMessage = "554 " + pResult->GetMessage();
+ EnqueueWrite_(sErrorMessage);
+ LogAwstatsMessageRejected_();
+ return;
+ }
+ case 3:
+ {
+ String sErrorMessage = "453 " + pResult->GetMessage();
+ EnqueueWrite_(sErrorMessage);
+ LogAwstatsMessageRejected_();
+ return;
+ }
+ }
+ }
+
EnqueueWrite_("250 Hello.");
if (current_state_ == INITIAL)