Is there a logfile for antispam results :?:

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-17 20:15

I have configured antispam on my hmailserver (5.6.7-B2425)
I defined a rule, that spam-emails are sent to a different email if the ranking is too high.
As the rule did some mails, I know, that it is basicly working.

But can I see somewhere a protocol of the work of antispam? I searched the logfiles, but without success.

BTW: Using hMailserver Administrator, i see in the menu-tree a red circle with a crossed line at the folder of Antispam. Is this ok?
Looks like the program wants to tell me, that antispam is not active...

regards/brutzler

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-17 20:40

What exactly would you like to see?

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-17 22:04

I would like to see infos from the spam-scanned mails:
- what spam ranking did they get
- what action did hMailserver with the Mails.

Because it looks like, that hmailserver (I use it for POP all my email-accounts from my provider to my local (h)mail-server with IMAP-accounts) does not pop any more all emails since I activated antispam.

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-17 22:41

You could log stuff to the event log. Put this code in OnAcceptMessage in EventHandlers.vbs:

Code: Select all

	REM - Log spam reasons 
	Dim Reason1, Reason2, Reason3, Reason4, Reason5, Reason6, Reason7  
	If (oMessage.HeaderValue("X-hMailServer-Spam") = "YES") Then
		EventLog.Write ("########   SPAM RECEIVED   ########")
		EventLog.Write ("Total Spam Score   : " & oMessage.HeaderValue("X-hMailServer-Reason-Score"))
		EventLog.Write ("Spam From          : " & oMessage.From)
		EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress
		EventLog.Write ("Spam To            : " & oMessage.Recipients(0).Address)
		If (oMessage.HeaderValue("X-hMailServer-Reason-0") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-0"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-1") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-1"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-2") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-2"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-3") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-3"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-4") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-4"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-5") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-5"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-6") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-6"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-7") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-7"))
	End If

Or you could set up a custom log.

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-17 22:55

OK
thanks for sharing the code.
I tried my best:

Searching for the file:
-> C:\Program Files (x86)\hMailServer\Events\EventHandlers.vbs
Its the right one, or?

Open it with notepad++ in admin mode, copy the lines from you:

Code: Select all

	
'   Sub OnAcceptMessage(oClient, oMessage)
REM - Log spam reasons 
	Dim Reason1, Reason2, Reason3, Reason4, Reason5, Reason6, Reason7  
	If (oMessage.HeaderValue("X-hMailServer-Spam") = "YES") Then
		EventLog.Write ("########   SPAM RECEIVED   ########")
		EventLog.Write ("Total Spam Score   : " & oMessage.HeaderValue("X-hMailServer-Reason-Score"))
		EventLog.Write ("Spam From          : " & oMessage.From)
		EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress
		EventLog.Write ("Spam To            : " & oMessage.Recipients(0).Address)
		If (oMessage.HeaderValue("X-hMailServer-Reason-0") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-0"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-1") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-1"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-2") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-2"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-3") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-3"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-4") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-4"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-5") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-5"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-6") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-6"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-7") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-7"))
	End If
'   End Sub
Then going to scripts, activate them and reload the scripts.
After this I get an error-log:

Code: Select all

"ERROR"	10172	"2020-05-17 22:48:33.043"	"Script Error: Source: Kompilierungsfehler in Microsoft VBScript - Error: 800A03EE - Description: ')' erwartet - Line: 14 Column: 64 - Code: 		EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress"
"ERROR"	10172	"2020-05-17 22:48:33.046"	"Severity: 2 (High), Code: HM5016, Source: ScriptServer::LoadScripts, Description: File: C:\Program Files (x86)\hMailServer\Events\EventHandlers.vbs[nl]Script Error: Source: Kompilierungsfehler in Microsoft VBScript - Error: 800A03EE - Description: ')' erwartet - Line: 14 Column: 64 - Code: 		EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress"
Oh, i see, there is a bracket missing at the end. I add the bracket and repeat the script loading:
Next error message:

Code: Select all

"ERROR"	5756	"2020-05-17 22:53:09.637"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 10 Column: 1 - Code: (null)"
"ERROR"	5756	"2020-05-17 22:53:09.637"	"Severity: 2 (High), Code: HM5016, Source: ScriptServer::LoadScripts, Description: File: C:\Program Files (x86)\hMailServer\Events\EventHandlers.vbs[nl]Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 10 Column: 1 - Code: (null)"
for this I have no solution

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-17 23:01

oh, me fool..

should remove the comment marks in front of the sub...

Now there is no error log on reloading the scripts.

But which sort of protocol has to be activated for the events?
- Application
- SMTP
- POP3
- IMAP
- TCP/IP
- Debug
- AWstats

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-18 00:18

brutzler wrote:
2020-05-17 23:01
oh, me fool..

should remove the comment marks in front of the sub...
Yes. 👍
Now there is no error log on reloading the scripts.

But which sort of protocol has to be activated for the events?
- Application
- SMTP
- POP3
- IMAP
- TCP/IP
- Debug
- AWstats
None. OnAcceptMessage is a scripting trigger so it will do whatever you tell it to do.

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 01:55

Hmmm..

I thought your script should write into a logfile, right?
But I do not find any :-(
Where (Which folder) should it be, and what should be the filename?

User avatar
mattg
Moderator
Moderator
Posts: 20895
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Is there a logfile for antispam results :?:

Post by mattg » 2020-05-18 03:39

That script writes to the hMailserver eventlog

typically
C:\Program Files (x86)\hMailServer\logs\hmailserver_events.log

But you can change that
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 08:06

Hi,

I did not change anything regarding path/filename.
But there is no hmailserver_events.log
Scripts are activated and syntaxcheck is ok.

Is "reload scripts" enough, or do I have to restart the whole hmailserver-service?

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-18 09:35

Reload is enough.

Hmailserver won't create the log until it has a need to. If hmailserver_events.log doesn't exist yet, that means you haven't received any spam since you enabled the script. Or, more precisely, hmailserver has not scored any messages as spam yet. :D

No spam. That's a nice lifestyle. I like that. It makes me think of sipping an exotic drink from a coconut shell on a tropical beach. :mrgreen:

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 11:14

When will this script be activated?
The script is called "Sub OnAcceptMessage(oClient, oMessage)"
In my opinion it is executed on every received email. Or not?
Because I thought the same and added a line at the beginning of the sub, where hmailserver should write a dummytext into the logfile.

Code: Select all

Sub OnAcceptMessage(oClient, oMessage)
EventLog.Write ("########   Mail RECEIVED   ########")  <===================================== added by brutzler
REM - Log spam reasons 
	Dim Reason1, Reason2, Reason3, Reason4, Reason5, Reason6, Reason7  
	If (oMessage.HeaderValue("X-hMailServer-Spam") = "YES") Then
		EventLog.Write ("########   SPAM RECEIVED   ########")
		.
		.
		.
		.
		
And there is still no logfile.

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-18 11:28

brutzler wrote:
2020-05-18 11:14
When will this script be activated?
The script is called "Sub OnAcceptMessage(oClient, oMessage)"
In my opinion it is executed on every received email. Or not?
Correct. Actually, all messages.
Because I thought the same and added a line at the beginning of the sub, where hmailserver should write a dummytext into the logfile.

Code: Select all

Sub OnAcceptMessage(oClient, oMessage)
EventLog.Write ("########   Mail RECEIVED   ########")  <===================================== added by brutzler
REM - Log spam reasons 
	Dim Reason1, Reason2, Reason3, Reason4, Reason5, Reason6, Reason7  
	If (oMessage.HeaderValue("X-hMailServer-Spam") = "YES") Then
		EventLog.Write ("########   SPAM RECEIVED   ########")
		.
		.
		.
		.
		
And there is still no logfile.
That should write to the event log on every message.

If you go to the settings for scripts, do you have VBScript selected?

Are you receiving mail? Try sending yourself a message.

Also, I'm not sure if this affects the event log or not, but do you have logging enabled?

User avatar
jimimaseye
Moderator
Moderator
Posts: 8634
Joined: 2011-09-08 17:48

Re: Is there a logfile for antispam results :?:

Post by jimimaseye » 2020-05-18 11:48

No it won't work because if this:
brutzler wrote:
2020-05-17 22:04
Because it looks like, that hmailserver (I use it for POP all my email-accounts from my provider....
That sub section is only for direct smtp delivered messages.

You should try moving it to the 'onexternaldownload' section.

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 12:02

OK, transferring the code from "OnAcceptMessage" to "OnExternalAccount" I get my added line for every mail in the expected file.
(After this i removed this testline.)
But the code from palinka is not working.

I get an error message:

Code: Select all

"ERROR"	9332	"2020-05-18 11:55:12.702"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 1 - Code: (null)"
And line 31 is the following:

Code: Select all

   Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
	REM - Log spam reasons 
	Dim Reason1, Reason2, Reason3, Reason4, Reason5, Reason6, Reason7  
>>line31>>	If (oMessage.HeaderValue("X-hMailServer-Spam") = "YES") Then
		EventLog.Write ("########   SPAM RECEIVED   ########")
		EventLog.Write ("Total Spam Score   : " & oMessage.HeaderValue("X-hMailServer-Reason-Score"))
		EventLog.Write ("Spam From          : " & oMessage.From)
		EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress)
		EventLog.Write ("Spam To            : " & oMessage.Recipients(0).Address)
		If (oMessage.HeaderValue("X-hMailServer-Reason-0") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-0"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-1") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-1"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-2") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-2"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-3") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-3"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-4") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-4"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-5") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-5"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-6") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-6"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-7") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-7"))
	End If
   End Sub

BTW jimimaseye:
onexternaldownload == OnExternalAccountDownload???

User avatar
jimimaseye
Moderator
Moderator
Posts: 8634
Joined: 2011-09-08 17:48

Re: Is there a logfile for antispam results :?:

Post by jimimaseye » 2020-05-18 12:15

brutzler wrote:
2020-05-18 12:02
jimimaseye:
onexternaldownload == OnExternalAccountDownload???
Yes.

Do a test. Remove the IF condition clause just to see if you get logging. Post the entire contents of your script file please.

More reference to subs: https://www.hmailserver.com/documentati ... ce_scripts

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 12:46

Hi,
the script is logging in deed:
out of the hmailserver_event.log

Code: Select all

9280	"2020-05-18 12:04:22.508"	"########   SPAM RECEIVED   ########"
9280	"2020-05-18 12:04:22.510"	"Total Spam Score   : 10"
9280	"2020-05-18 12:04:22.511"	"Spam From          : Hermenegild <hermenegildnphnxjp@papernom.com>"
9280	"2020-05-18 12:04:22.512"	"Spam Envelope From : hermenegildnphnxjp@papernom.com"
9280	"2020-05-18 12:04:22.513"	"Spam To            : xxxx@yyyyyyyyyy.de"
9280	"2020-05-18 12:04:22.517"	"Spam Reason        : Sender domain does not have any MX records. - (Score: 2)"
9280	"2020-05-18 12:04:22.518"	"Spam Reason        : Rejected by SURBL. - (Score: 3)"
9280	"2020-05-18 12:04:22.519"	"Spam Reason        : Rejected by DKIM. - (Score: 5)"
That is what I expected.

But sometimes I have some entries in the "ERROR_hmailserver_2020-05-18.log"

Code: Select all

"ERROR"	9332	"2020-05-18 12:01:18.717"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 1 - Code: (null)"
Thats what I showed you in the last posts.
Until now, I could not figure out, when and why.

Runtime Error means for me, that something is wrong in the code. But when I look at the hmailserver_event.log, the code looks working.



Here the entire script:

Code: Select all

'   Sub OnClientConnect(oClient)
'   End Sub

'   Sub OnSMTPData(oClient, oMessage)
'   End Sub

'   Sub OnAcceptMessage(oClient, oMessage)
'   End Sub

'   Sub OnDeliveryStart(oMessage)
'   End Sub

'   Sub OnDeliverMessage(oMessage)
'   End Sub

'   Sub OnBackupFailed(sReason)
'   End Sub

'   Sub OnBackupCompleted()
'   End Sub

'   Sub OnError(iSeverity, iCode, sSource, sDescription)
'   End Sub

'   Sub OnDeliveryFailed(oMessage, sRecipient, sErrorMessage)
'   End Sub

   Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
	REM - Log spam reasons 
	Dim Reason1, Reason2, Reason3, Reason4, Reason5, Reason6, Reason7  
	If (oMessage.HeaderValue("X-hMailServer-Spam") = "YES") Then
		EventLog.Write ("########   SPAM RECEIVED   ########")
		EventLog.Write ("Total Spam Score   : " & oMessage.HeaderValue("X-hMailServer-Reason-Score"))
		EventLog.Write ("Spam From          : " & oMessage.From)
		EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress)
		EventLog.Write ("Spam To            : " & oMessage.Recipients(0).Address)
		If (oMessage.HeaderValue("X-hMailServer-Reason-0") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-0"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-1") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-1"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-2") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-2"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-3") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-3"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-4") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-4"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-5") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-5"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-6") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-6"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-7") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-7"))
	End If
   End Sub

User avatar
SorenR
Senior user
Senior user
Posts: 3620
Joined: 2006-08-21 15:38
Location: Denmark

Re: Is there a logfile for antispam results :?:

Post by SorenR » 2020-05-18 14:08

If you add a line

On Error Resume Next

just after the line "REM - Log spam reasons" the error will magically go away - it will not solve the issue, but the error will go away.

There is something fundamentally wrong somewhere and I'm wondering if the problem is oMessage not being initialised by hMailServer so it becomes an empty object.
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

User avatar
jimimaseye
Moderator
Moderator
Posts: 8634
Joined: 2011-09-08 17:48

Re: Is there a logfile for antispam results :?:

Post by jimimaseye » 2020-05-18 14:40

SorenR wrote:
2020-05-18 14:08
There is something fundamentally wrong somewhere and I'm wondering if the problem is oMessage not being initialised by hMailServer
+1

And if true it's likely that the testing of the headers (as initially required) will not be possible in this section.
[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-18 14:44

jimimaseye wrote:
2020-05-18 14:40
SorenR wrote:
2020-05-18 14:08
There is something fundamentally wrong somewhere and I'm wondering if the problem is oMessage not being initialised by hMailServer
+1

And if true it's likely that the testing of the headers (as initially required) will not be possible in this section.
[Entered by mobile. Excuse my spelling.]
What could cause this? I don't think any configuration error could be the cause.

User avatar
jimimaseye
Moderator
Moderator
Posts: 8634
Joined: 2011-09-08 17:48

Re: Is there a logfile for antispam results :?:

Post by jimimaseye » 2020-05-18 15:13

I think an error in hmailserver itself although I'm pretty sure a similar solution was proposed and adapted a couple of weeks ago for someone else. Maybe someone has an account that uses external downloads to do a test of the omessage object. Also perhaps test against 5.7.

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
SorenR
Senior user
Senior user
Posts: 3620
Joined: 2006-08-21 15:38
Location: Denmark

Re: Is there a logfile for antispam results :?:

Post by SorenR » 2020-05-18 15:45

I would not be surprised if oMessage only get populated when there are mails waiting...

Looking at events.cpp I came across this...

Code: Select all

         if (pMessage)
            sEventCaller.Format(_T("OnExternalAccountDownload(HMAILSERVER_FETCHACCOUNT, HMAILSERVER_MESSAGE, \"%s\")"), sRemoteUIDCopy.c_str());
         else
            sEventCaller.Format(_T("OnExternalAccountDownload(HMAILSERVER_FETCHACCOUNT, Nothing, \"%s\")"), sRemoteUIDCopy.c_str());
so ... maybe ... "If oMessage Is Nothing Then Exit Sub" ??

https://developer.rhino3d.com/guides/rh ... mpty-null/
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

User avatar
jimimaseye
Moderator
Moderator
Posts: 8634
Joined: 2011-09-08 17:48

Re: Is there a logfile for antispam results :?:

Post by jimimaseye » 2020-05-18 17:51

Should work.

I use this method in the diag script and, funnily enough, I have just had to change it for another occurence of this method (line 1138).

so

Code: Select all

Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
   REM - Log spam reasons 
   Dim Reason1, Reason2, Reason3, Reason4, Reason5, Reason6, Reason7  
   If not oMessage is Nothing and oMessage.HeaderValue("X-hMailServer-Spam") = "YES" Then
      EventLog.Write ("########   SPAM RECEIVED   ########")
      EventLog.Write ("Total Spam Score   : " & oMessage.HeaderValue("X-hMailServer-Reason-Score"))
      EventLog.Write ("Spam From          : " & oMessage.From)
      EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress)
      EventLog.Write ("Spam To            : " & oMessage.Recipients(0).Address)
      If (oMessage.HeaderValue("X-hMailServer-Reason-0") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-0"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-1") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-1"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-2") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-2"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-3") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-3"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-4") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-4"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-5") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-5"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-6") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-6"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-7") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-7"))
   End If
End Sub

EDIT: Come to think of it I have encountered this very issue before with 'OnExternalAccountDownload' and catered for it with this method in my production scripts. But forgot.
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-18 18:15

Can delete this line too.

Code: Select all

 Dim Reason1, Reason2, Reason3, Reason4, Reason5, Reason6, Reason7  
Its a remnant from where I copied it.

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 19:30

hmailserver with the "on error resume next" -line did now run for 8h.
Thats the result of the hmailserver_events.log
Very often I have only the "SPAM RECEIVED" -line:
To say: the log-file has atm ~ 12000 lines. And there are 50 detailed spam messages. The rest is only the "SPAM RECEIVED" -line

Code: Select all

2856	"2020-05-18 15:41:56.016"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.016"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.016"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.016"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.016"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.031"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.031"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.031"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.031"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.031"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.031"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.031"	"########   SPAM RECEIVED   ########"
2856	"2020-05-18 15:41:56.047"	"########   SPAM RECEIVED   ########"
9280	"2020-05-18 15:41:56.250"	"########   SPAM RECEIVED   ########"
9280	"2020-05-18 15:41:56.250"	"Total Spam Score   : 10"
9280	"2020-05-18 15:41:56.250"	"Spam From          : Gisbert <gisbertetthffk@lawapass.com>"
9280	"2020-05-18 15:41:56.250"	"Spam Envelope From : gisbertetthffk@lawapass.com"
9280	"2020-05-18 15:41:56.250"	"Spam To            : xxxxx@yyyyyyyy.de"
9280	"2020-05-18 15:41:56.250"	"Spam Reason        : Rejected by SURBL. - (Score: 3)"
9280	"2020-05-18 15:41:56.250"	"Spam Reason        : Rejected by DKIM. - (Score: 5)"
9280	"2020-05-18 15:41:56.250"	"Spam Reason        : Sender domain does not have any MX records. - (Score: 2)"
4328	"2020-05-18 15:43:57.665"	"########   SPAM RECEIVED   ########"
4328	"2020-05-18 15:43:57.680"	"########   SPAM RECEIVED   ########"
4328	"2020-05-18 15:43:57.680"	"########   SPAM RECEIVED   ########"
4328	"2020-05-18 15:43:57.696"	"########   SPAM RECEIVED   ########"
4328	"2020-05-18 15:43:57.696"	"########   SPAM RECEIVED   ########"
4328	"2020-05-18 15:43:57.696"	"########   SPAM RECEIVED   ########"
4328	"2020-05-18 15:43:57.712"	"########   SPAM RECEIVED   ########"
4328	"2020-05-18 15:43:57.712"	"########   SPAM RECEIVED   ########"
4328	"2020-05-18 15:43:57.712"	"########   SPAM RECEIVED   ########"
4328	"2020-05-18 15:43:57.727"	"########   SPAM RECEIVED   ########"
4328	"2020-05-18 15:43:57.727"	"########   SPAM RECEIVED   ########"
4328	"2020-05-18 15:43:57.727"	"########   SPAM RECEIVED   ########"
9332	"2020-05-18 15:44:58.692"	"########   SPAM RECEIVED   ########"
9332	"2020-05-18 15:44:58.692"	"########   SPAM RECEIVED   ########"
9332	"2020-05-18 15:44:58.708"	"########   SPAM RECEIVED   ########"
9332	"2020-05-18 15:44:58.708"	"########   SPAM RECEIVED   ########"
9332	"2020-05-18 15:44:58.723"	"########   SPAM RECEIVED   ########"
9332	"2020-05-18 15:44:58.723"	"########   SPAM RECEIVED   ########"
9332	"2020-05-18 15:44:58.739"	"########   SPAM RECEIVED   ########"
9332	"2020-05-18 15:44:58.739"	"########   SPAM RECEIVED   ########"
9332	"2020-05-18 15:44:58.739"	"########   SPAM RECEIVED   ########"
9332	"2020-05-18 15:44:58.739"	"########   SPAM RECEIVED   ########"
You think, I should modify this line too?

Code: Select all

   If not oMessage is Nothing and oMessage.HeaderValue("X-hMailServer-Spam") = "YES" Then

User avatar
jimimaseye
Moderator
Moderator
Posts: 8634
Joined: 2011-09-08 17:48

Re: Is there a logfile for antispam results :?:

Post by jimimaseye » 2020-05-18 19:38

I posted the code you should use in my last post.

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-18 19:38

Yes.

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 20:44

jimimaseye wrote:
2020-05-18 19:38
I posted the code you should use in my last post.

[Entered by mobile. Excuse my spelling.]
I tried and again the error messages with the runtime error:

Code: Select all

"ERROR"	2060	"2020-05-18 20:42:51.670"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
Error messages accur in "ERROR_hmailserver_2020-05-18.log" as soon as i load the script and on every POP-run

User avatar
jimimaseye
Moderator
Moderator
Posts: 8634
Joined: 2011-09-08 17:48

Re: Is there a logfile for antispam results :?:

Post by jimimaseye » 2020-05-18 21:27

Show the script please.

Also did you 'reload' the script after changing it?

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 21:35

I copied it directly from your post.
And YES, I reloaded the script.

Code: Select all

  Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
   REM - Log spam reasons 
   Dim Reason1, Reason2, Reason3, Reason4, Reason5, Reason6, Reason7  
   If not oMessage is Nothing and oMessage.HeaderValue("X-hMailServer-Spam") = "YES" Then
   'If (oMessage.HeaderValue("X-hMailServer-Spam") = "YES") Then
      EventLog.Write ("########   SPAM RECEIVED   ########")
      EventLog.Write ("Total Spam Score   : " & oMessage.HeaderValue("X-hMailServer-Reason-Score"))
      EventLog.Write ("Spam From          : " & oMessage.From)
      EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress)
      EventLog.Write ("Spam To            : " & oMessage.Recipients(0).Address)
      If (oMessage.HeaderValue("X-hMailServer-Reason-0") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-0"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-1") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-1"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-2") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-2"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-3") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-3"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-4") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-4"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-5") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-5"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-6") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-6"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-7") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-7"))
	End If
	End Sub

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 21:49

Hey,

just one idea:
As I told you, I make POP3 from my external provider.

Just right now on testing the Anti-Spam and not to lose any important email, I configured the external account that the emails are not deleted at once, but stay for one day.
I see, in the "normal" log, that the external account tells me, there are 12 "old" emails, and after this I get 12 of the error messages.
Maybe that is the reason?

Code: Select all

"DEBUG"	8840	"2020-05-18 21:37:45.300"	"Adding task ExternalFetchTask to work queue External fetch queue"
"DEBUG"	3396	"2020-05-18 21:37:45.300"	"Executing task ExternalFetchTask in work queue External fetch queue"
"DEBUG"	3396	"2020-05-18 21:37:45.300"	"Retrieving messages from external account xxx@yyy.de"
"DEBUG"	3396	"2020-05-18 21:37:45.300"	"Creating session 1189"
"DEBUG"	9632	"2020-05-18 21:37:45.316"	"TCP connection started for session 1189"
"DEBUG"	9632	"2020-05-18 21:37:45.316"	"Performing SSL/TLS handshake for session 1189. Verify certificate: True, Expected remote host name: pop.provider.de"
"DEBUG"	9632	"2020-05-18 21:37:45.347"	"Certificate verification succeeded for session 1189."
"POP3C"	9632	1189	"2020-05-18 21:37:45.597"	"222.222.222.111"	"RECEIVED: +OK POP server ready H mieue153 1M41Sw-1jalZ40zrs-045kD7"
"POP3C"	9632	1189	"2020-05-18 21:37:45.597"	"222.222.222.111"	"SENT: USER xxx@yyy.de"
"POP3C"	9276	1189	"2020-05-18 21:37:45.612"	"222.222.222.111"	"RECEIVED: +OK password required for user "xxx@yyy.de""
"POP3C"	9276	1189	"2020-05-18 21:37:45.612"	"222.222.222.111"	"SENT: ***"
"POP3C"	9276	1189	"2020-05-18 21:37:45.644"	"222.222.222.111"	"RECEIVED: +OK mailbox "xxx@yyy.de" has 12 messages (1310985 octets) H mieue153"
"POP3C"	9276	1189	"2020-05-18 21:37:45.644"	"222.222.222.111"	"SENT: UIDL"
"POP3C"	2060	1189	"2020-05-18 21:37:45.659"	"222.222.222.111"	"RECEIVED: +OK[nl]1 1M2vjm-1jdtb1jDw-003KDanl]2 1MWil6-1jYQX0cSO-00X7Ei[nl]3 1Mog5B-1jHG373VYP-00p3OK[nl]4 1MJmvv-1jLP5J09sH-00KAwN[nl]5 1MMFRG-1jJU7Q3aaM-00JKtM[nl]6 1Mhks2-1j5xhW00dU-0dk0i[nl]7 1MfIAH-1j7sW0zNL-00gm1M[nl]8 1MEn2D-1jpm0W0Tz1-00GtB[nl]9 1M8A4J1jekRK0Zv-005Ij[nl]10 1MKawm-1jME6c3YWS00KvTn[nl]11 1N3smG-1isF63Upc-00zrSa[nl]12 1MP0nc-1jQt9F0ypI-00PJAi[nl]."
"DEBUG"	2060	"2020-05-18 21:37:45.659"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.659"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.675"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.675"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.675"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.675"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.675"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.675"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.690"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.690"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.690"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.690"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.690"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.690"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.706"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.706"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.706"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.706"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.706"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.706"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.706"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.706"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.722"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.722"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.722"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.722"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.722"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.722"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.722"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.722"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.722"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.722"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.722"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.722"	"Executing event OnExternalAccountDownload"
"ERROR"	2060	"2020-05-18 21:37:45.722"	"Script Error: Source: Laufzeitfehler in Microsoft VBScript - Error: 800A01A8 - Description: Objekt erforderlich: 'oMessage' - Line: 31 Column: 3 - Code: (null)"
"DEBUG"	2060	"2020-05-18 21:37:45.737"	"Event completed"
"DEBUG"	2060	"2020-05-18 21:37:45.737"	"POP3 External Account: Normal QUIT."
"POP3C"	2060	1189	"2020-05-18 21:37:45.737"	"222.222.222.111"	"SENT: QUIT"
"POP3C"	9384	1189	"2020-05-18 21:37:45.753"	"222.222.222.111"	"RECEIVED: +OK POP server signing off"
"DEBUG"	9384	"2020-05-18 21:37:45.753"	"Ending session 1189"
"DEBUG"	3396	"2020-05-18 21:37:45.753"	"Completed retrieval of messages from external account."

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-18 21:55

SorenR wrote:
2020-05-18 15:45
I would not be surprised if oMessage only get populated when there are mails waiting...

Looking at events.cpp I came across this...

Code: Select all

         if (pMessage)
            sEventCaller.Format(_T("OnExternalAccountDownload(HMAILSERVER_FETCHACCOUNT, HMAILSERVER_MESSAGE, \"%s\")"), sRemoteUIDCopy.c_str());
         else
            sEventCaller.Format(_T("OnExternalAccountDownload(HMAILSERVER_FETCHACCOUNT, Nothing, \"%s\")"), sRemoteUIDCopy.c_str());
so ... maybe ... "If oMessage Is Nothing Then Exit Sub" ??

https://developer.rhino3d.com/guides/rh ... mpty-null/
brutzler wrote:
2020-05-18 21:49
Hey,

just one idea:
As I told you, I make POP3 from my external provider.

Just right now on testing the Anti-Spam and not to lose any important email, I configured the external account that the emails are not deleted at once, but stay for one day.
I see, in the "normal" log, that the external account tells me, there are 12 "old" emails, and after this I get 12 of the error messages.
Maybe that is the reason?
Sounds about right. Try "If oMessage Is Nothing Then Exit Sub".

Try this

Code: Select all

Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
	REM - Log spam reasons 
	If oMessage Is Nothing Then 
		Exit Sub
	Else If oMessage.HeaderValue("X-hMailServer-Spam") = "YES" Then
		EventLog.Write ("########   SPAM RECEIVED   ########")
		EventLog.Write ("Total Spam Score   : " & oMessage.HeaderValue("X-hMailServer-Reason-Score"))
		EventLog.Write ("Spam From          : " & oMessage.From)
		EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress)
		EventLog.Write ("Spam To            : " & oMessage.Recipients(0).Address)
		If (oMessage.HeaderValue("X-hMailServer-Reason-0") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-0"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-1") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-1"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-2") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-2"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-3") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-3"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-4") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-4"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-5") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-5"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-6") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-6"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-7") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-7"))
	End If
End Sub

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 22:01

palinka wrote:
2020-05-18 21:55
Try "If oMessage Is Nothing Then Exit Sub".
Already added..
But imho, this is then enough, or? No need for the marked line.

Code: Select all

   Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
   REM - Log spam reasons 
   Dim Reason1, Reason2, Reason3, Reason4, Reason5, Reason6, Reason7  
   If oMessage Is Nothing Then Exit Sub
   'If not oMessage is Nothing and oMessage.HeaderValue("X-hMailServer-Spam") = "YES" Then   <-------------------------------------
   If (oMessage.HeaderValue("X-hMailServer-Spam") = "YES") Then
waiting for results... :-)
Last edited by brutzler on 2020-05-18 22:04, edited 1 time in total.

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-18 22:03

brutzler wrote:
2020-05-18 22:01
palinka wrote:
2020-05-18 21:55
Try "If oMessage Is Nothing Then Exit Sub".
Already added..
But imho, this is then enough, or? No need for the marked line.
Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
REM - Log spam reasons
Dim Reason1, Reason2, Reason3, Reason4, Reason5, Reason6, Reason7
If oMessage Is Nothing Then Exit Sub
'If not oMessage is Nothing and oMessage.HeaderValue("X-hMailServer-Spam") = "YES" Then <-------------------------------------
If (oMessage.HeaderValue("X-hMailServer-Spam") = "YES") Then
waiting for results... :-)
I edited my post while you were posting - see my last post.

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 22:05

I see.... :lol:

OK, you have an additional "else"

User avatar
jimimaseye
Moderator
Moderator
Posts: 8634
Joined: 2011-09-08 17:48

Re: Is there a logfile for antispam results :?:

Post by jimimaseye » 2020-05-18 22:20

Try this:

Code: Select all

 Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
   REM - Log spam reasons   
   If not oMessage is Nothing then
   If oMessage.HeaderValue("X-hMailServer-Spam") = "YES" Then
      EventLog.Write ("########   SPAM RECEIVED   ########")
      EventLog.Write ("Total Spam Score   : " & oMessage.HeaderValue("X-hMailServer-Reason-Score"))
      EventLog.Write ("Spam From          : " & oMessage.From)
      EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress)
      EventLog.Write ("Spam To            : " & oMessage.Recipients(0).Address)
      If (oMessage.HeaderValue("X-hMailServer-Reason-0") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-0"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-1") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-1"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-2") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-2"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-3") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-3"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-4") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-4"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-5") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-5"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-6") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-6"))
      If (oMessage.HeaderValue("X-hMailServer-Reason-7") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-7"))
		End If
	END IF
End Sub
[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 22:21

palinka wrote:
2020-05-18 21:55

Try this

Code: Select all

Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
	REM - Log spam reasons 
	If oMessage Is Nothing Then 
		Exit Sub
	Else If oMessage.HeaderValue("X-hMailServer-Spam") = "YES" Then
		EventLog.Write ("########   SPAM RECEIVED   ########")
		EventLog.Write ("Total Spam Score   : " & oMessage.HeaderValue("X-hMailServer-Reason-Score"))
		EventLog.Write ("Spam From          : " & oMessage.From)
		EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress)
		EventLog.Write ("Spam To            : " & oMessage.Recipients(0).Address)
		If (oMessage.HeaderValue("X-hMailServer-Reason-0") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-0"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-1") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-1"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-2") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-2"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-3") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-3"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-4") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-4"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-5") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-5"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-6") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-6"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-7") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-7"))
	End If
End Sub
Compiling error. :mrgreen:
I suggest a second "End If"

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-18 22:38

brutzler wrote:
2020-05-18 22:21
palinka wrote:
2020-05-18 21:55

Try this

Code: Select all

Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
	REM - Log spam reasons 
	If oMessage Is Nothing Then 
		Exit Sub
	Else If oMessage.HeaderValue("X-hMailServer-Spam") = "YES" Then
		EventLog.Write ("########   SPAM RECEIVED   ########")
		EventLog.Write ("Total Spam Score   : " & oMessage.HeaderValue("X-hMailServer-Reason-Score"))
		EventLog.Write ("Spam From          : " & oMessage.From)
		EventLog.Write ("Spam Envelope From : " & oMessage.FromAddress)
		EventLog.Write ("Spam To            : " & oMessage.Recipients(0).Address)
		If (oMessage.HeaderValue("X-hMailServer-Reason-0") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-0"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-1") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-1"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-2") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-2"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-3") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-3"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-4") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-4"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-5") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-5"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-6") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-6"))
		If (oMessage.HeaderValue("X-hMailServer-Reason-7") <> "") Then EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-7"))
	End If
End Sub
Compiling error. :mrgreen:
I suggest a second "End If"
No, it's ElseIf. I always get ElseIf and Else If confused.

brutzler
Normal user
Normal user
Posts: 64
Joined: 2018-11-21 23:37

Re: Is there a logfile for antispam results :?:

Post by brutzler » 2020-05-18 22:49

imho a lot of possibilities.
But looks good now.
Log working as expected. and no error messages.

Finaly question for my interest:
Is there any documentation for all possible sub-classes of 'oMessage'
I have seen the following:
- oMessage.HeaderValue
- oMessage.From
- oMessage.FromAddress
- oMessage.Recipients(0).Address

Think there is more....


BTW:
:!: :!: :!: Big Thanks for your help :!: :!: :!:

User avatar
jimimaseye
Moderator
Moderator
Posts: 8634
Joined: 2011-09-08 17:48

Re: Is there a logfile for antispam results :?:

Post by jimimaseye » 2020-05-18 22:51

5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-18 22:55

You can probably start with the link at the top that says "documentation". :lol:

User avatar
mattg
Moderator
Moderator
Posts: 20895
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Is there a logfile for antispam results :?:

Post by mattg » 2020-05-19 01:05

SorenR wrote:
2020-05-18 15:45
I would not be surprised if oMessage only get populated when there are mails waiting...
Yes correct
And also once for EACH message waiting
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
jimimaseye
Moderator
Moderator
Posts: 8634
Joined: 2011-09-08 17:48

Re: Is there a logfile for antispam results :?:

Post by jimimaseye » 2020-05-19 01:27

Yes. As previously determined.

[quoteoMessage - The message which has been downloaded. If the message has already been downloaded before, this parameter will be Nothing / Null][/quote]

https://www.hmailserver.com/documentati ... ntdownload

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
SorenR
Senior user
Senior user
Posts: 3620
Joined: 2006-08-21 15:38
Location: Denmark

Re: Is there a logfile for antispam results :?:

Post by SorenR » 2020-05-19 10:50

Just had a weird experience...

In the beginning of my EventHandlers.vbs I set several constants, one is named "PASSWORD" and is the password of my Amin user for when doing "Call m_oApp.Authenticate(ADMIN, PASSWORD)"...

I changed my GMail account today from automatic forward to allowing POP access and created an "External account" on my account.

When there is new mail in my GMail I get this:

Code: Select all

"ERROR"	1432	"2020-05-19 10:25:54.669"	"Script Error: Source: Microsoft VBScript runtime error - Error: 800A0411 - Description: Name redefined: 'PASSWORD' - Line: 11 Column: 0 - Code: (null)"
So I did a Search/Replace All in my script changing PASSWORD to PASSWD ...

The error is now gone ... (o)(O) ... WTF ??? hMailServer (RvdH+) 5.6.8-B2505.27
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

User avatar
SorenR
Senior user
Senior user
Posts: 3620
Joined: 2006-08-21 15:38
Location: Denmark

Re: Is there a logfile for antispam results :?:

Post by SorenR » 2020-05-19 12:32

Ok, the PASSWORD problem is now verified by this code snippet

There is NO "Dim password" anywhere in my script!

Code: Select all

    '
    '   Any messages?
    '
    If oMessage Is Nothing Then
        Exit Sub
    Else
        If Not IsEmpty(password) Then EventLog.Write("FetchAccount=" & oFetchAccount.Username & " Password=" & password)
    End If
Output is the email address and the password (!!) so the variable "password" is equal to "oFetchAccount.Password" ... Hmm ... Am I missing something?
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

User avatar
SorenR
Senior user
Senior user
Posts: 3620
Joined: 2006-08-21 15:38
Location: Denmark

Re: Is there a logfile for antispam results :?:

Post by SorenR » 2020-05-19 13:26

Anyways - my script.

Code: Select all

Sub OnExternalAccountDownload(oFetchAccount, oMessage, sRemoteUID)
    Dim i, Done, strTo, strOriginalTo
    '
    '   Safeguard ON ;-)
    '
    Rem On Error Resume Next
    '
    '   Any messages?
    '
    If oMessage Is Nothing Then Exit Sub
    '
    '   Got SPAM?
    '
    If (oMessage.HeaderValue("X-hMailServer-Spam") = "YES") Then
        EventLog.Write ("########   SPAM RECEIVED   ########")
        EventLog.Write ("Total Spam Score              : " & oMessage.HeaderValue("X-hMailServer-Reason-Score"))
        EventLog.Write ("Spam (Header) From            : " & oMessage.From)
        EventLog.Write ("Spam (Header) To              : " & oMessage.To)
        EventLog.Write ("Spam (Header) Cc              : " & oMessage.Cc)
        '
        '   Extract Envelope addressing = SMTP conversation, non-spoofable.
        '
        For i = 0 To oMessage.Recipients.Count-1
            If (i = 0) Then
                strTo = oMessage.Recipients(i).Address
                strOriginalTo = oMessage.Recipients(i).OriginalAddress
            Else
                strTo = strTo & ", " & oMessage.Recipients(i).Address
                strOriginalTo = strOriginalTo & ", " & oMessage.Recipients(i).OriginalAddress
            End If
        Next
        EventLog.Write ("Spam (Envelope) From          : " & oMessage.FromAddress)
        EventLog.Write ("Spam (Envelope) To            : " & strTo)
        EventLog.Write ("Spam (Envelope) To (Original) : " & strOriginalTo)
        '
        '   List all results of hMailServer SPAM detections, 0 to howevermanydefined
        '
        i = 1 : Done = False
        Do Until Done
            If (oMessage.HeaderValue("X-hMailServer-Reason-" & i) = "") Then Exit Do
            EventLog.Write ("Spam Reason        : " & oMessage.HeaderValue("X-hMailServer-Reason-" & i))
            i = i + 1
            '
            '   Failsafe ;-)
            '
            If i = 20 Then Done = True
        Loop
    End If
    '
    '   Safeguard OFF ;-)
    '
    Rem On Error GoTo 0
End Sub
SørenR.

“Those who don't know history are doomed to repeat it.”
― Edmund Burke

palinka
Senior user
Senior user
Posts: 1964
Joined: 2017-09-12 17:57

Re: Is there a logfile for antispam results :?:

Post by palinka » 2020-05-19 14:51

SorenR wrote:
2020-05-19 12:32
Output is the email address and the password (!!) so the variable "password" is equal to "oFetchAccount.Password" ... Hmm ... Am I missing something?
Interesting. A new toy to play with. :D

Post Reply