Oddity in the subject text

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
Hotlanta
Normal user
Normal user
Posts: 46
Joined: 2006-12-04 20:46

Oddity in the subject text

Post by Hotlanta » 2006-12-21 22:11

I've noticed that occasionally, the subject text of an email rejected by a black list doesn't get the [SPAM] text added to the subject text. I've tried doing it manually, and it fails in the script as well. Here is an example of one that failed (they're all similar):
Subject: =?windows-1251?B?W1NQQU0gQkxdIFszXTog8eDs++kg//Dq6Okg7/Dg5+Tt6Oog4+7k4CDx?=
=?windows-1251?B?8uDt5fIg7eXn4OH74uDl7PvsICEg?=
This SHOULD have had "[SPAM]" on the front of it since it had been rejected by spamhaus, but for some reason, any attempt to put it on the front of these odd email subjects seems to fail.

Notice that the first part of the line seems to always relate to some foreign charset. Is it possible there are nulls in the string? If so, is there a way to remove them? The vbs replace() function didn't work using chr(0).

I thought it might have to do with the length of the text, so I decide to cut off the end of it, and add my "[SPAM] " message to the front. I did this using the "Left()" function in VBS. It didn't help, and now I see errors in the logs as:

"ERROR" 1836 "2006-12-21 11:46:35.515" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A0005 - Description: Invalid procedure call or argument: 'Left' - Line: 234 Column: 3 - Code: (null)"
When I check the subject text with IsNull(), it passes. When I use cStr() to make sure it's a string, it makes no difference.

1. I can't figure out why the Left() function is failing.

2. I can't figure out why I (and hmailserver as well) can't prepend the "[SPAM]" message to some subject headers.

Any ideas?

Regards,

John

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2006-12-21 22:47

Fishy. Sounds like a bug to me. I'll give this a try tomorrow and see if I can reproduce it.

tonda
Normal user
Normal user
Posts: 93
Joined: 2006-10-20 14:13
Location: CZ

Post by tonda » 2006-12-22 00:10

Hm, I think that this can be the same problem I described in my post about characters with diactitical marks in Recipient address. In my script I do not work with Subject of message, but I think that address of recipient with diacritical marks can behave simillar to Subject mentioned here.

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2006-12-22 21:37

Haven't had time to look into it yet. Will try tomorrow again.
Agree with tonda that it sounds somewhat similar to his problem.

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2006-12-24 23:14

That subject actually appears to have the SPAM text added. If I decode the string in your first post, it starts with "[SPAM BL]". If I

send that subject line to myself, the text [SPAM BL] is shown as subject when I list the email in Outlook Express. I also tried to add a rule which filters on the text "[SPAM BL]", which also worked fine. When hMailServer adds a [SPAM] tag to a subject, it first decodes the subject line, adds the text and then encodes it again.

tonda
Normal user
Normal user
Posts: 93
Joined: 2006-10-20 14:13
Location: CZ

Post by tonda » 2006-12-27 18:09

Martin, is there any advance in problem of why Left() function is failing with runtime error, described in first post of Hotlanta? I described simillar problem with addresses mistakenly containing characters with diacritical marks here (http://www.hmailserver.com/forum/viewtopic.php?t=7040).

Background: I use SpamAssassin and I want to log SA score of every message checked in order to be able adjust SA settings. During OnDeliverMessage I call spamc and modify message file. Than I need access "X-Spam-Status" header, newly added by SA, but it is not possible to use oMessage.Header, because oMessage does not contain these newly added headers. So I must open message file as TextStream and iterate through few first lines and look for this header. When line processed contains such problematic string, hMailServer service terminates unexpectedly without any error message described by Hotlanta. (on both my hMailServer installations on W2000 Server. I use last stable release of hMailServer).
At least I would want to check first character of such problematic string without call of Left() or any other simmilar string function. Is it possible? I tried to retype string to array of char and than access to first char of this array but without success, VBScript is not my cup of coffee... Or is there any other possibility how to perform above mentioned logging or any other possibility how to debug ?

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2006-12-27 18:23

As I wrote in the other thread, I have been unable to reproduce it. I asked for some info in that thread a week ago, but haven't received any yet. If I can just reproduce the problem, it should be fairly enough to fix or come up with a workaround. But without being able to reproduce it, it's much harder to solve. :-\

tonda
Normal user
Normal user
Posts: 93
Joined: 2006-10-20 14:13
Location: CZ

Post by tonda » 2006-12-27 18:56

Just sending mail with script source, logs and server test setup...

Hotlanta
Normal user
Normal user
Posts: 46
Joined: 2006-12-04 20:46

Post by Hotlanta » 2006-12-27 21:54

martin wrote:That subject actually appears to have the SPAM text added. If I decode the string in your first post, it starts with "[SPAM BL]". If I send that subject line to myself, the text [SPAM BL] is shown as subject when I list the email in Outlook Express. I also tried to add a rule which filters on the text "[SPAM BL]", which also worked fine. When hMailServer adds a [SPAM] tag to a subject, it first decodes the subject line, adds the text and then encodes it again.
I use Eudora, not Outlook, so maybe Eudora is simply having trouble decoding for these character sets when it's displaying this foreign based email. "[SPAM BL]" is what I have hMailServer put in the header if it fails the Spamhaus check.

When you're decoding the subject line, how do you know if something is encoded with a different charset? Since I'm updating subject lines in my own code, it would be helpful to know the algorithms you use to decode and encode this text with. I notice the same issue also occurs with the "From" header.

User avatar
dzekas
Senior user
Senior user
Posts: 2486
Joined: 2005-10-13 21:28
Location: Lithuania

Post by dzekas » 2006-12-27 22:23

Hotlanta wrote: When you're decoding the subject line, how do you know if something is encoded with a different charset?
See RFC 2047.

Post Reply