Diacritical marks in oMessage addresses

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
tonda
Normal user
Normal user
Posts: 93
Joined: 2006-10-20 14:13
Location: CZ

Diacritical marks in oMessage addresses

Post by tonda » 2006-12-20 13:15

I perform some logging to file during OnAcceptMessage using oMessage.Recipients collection. One user sent message with mistyped diacritical marks in address and hMailServer service hung up. Last log file item was logged just before trying to access oMessage.Recipients(0).Address.
The same logging script works for me without any error for several weeks, so the only difference was usage of chars with diacritical marks in address.

Where is the problem? VBScript? How to handle it?

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

Post by martin » 2006-12-20 18:01

A bit hard to give a final solution with that info.
Are you sure it was the diacritical marks which solved it? Can you reproduce it? Does it work if you disable the VBScript?

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

Post by tonda » 2006-12-20 18:21

Try to use this script:

const csLogFileName = "C:\Program Files\hMailServer\Logs\mailstat.log"
const cbLogCreate = True

Sub WriteLog(cString)
if cbLogCreate then
Dim ofs, ofil
SET ofs = CreateObject("Scripting.Filesystemobject")
SET ofil = ofs.OpenTextFile(csLogFileName, 8, True)
ofil.writeline(Now & " - " & cString)
oFil.close
SET ofil = nothing
SET ofs = nothing
end if
end sub

Sub OnAcceptMessage(oClient, oMessage)
Dim qtyRecipients, oRecipients
WriteLog(oMessage.ID & " - From: " & oMessage.From)
WriteLog(oMessage.ID & " - To: " & oMessage.To)
WriteLog(oMessage.ID & " - Subject: " & oMessage.Subject)
qtyRecipients = oMessage.Recipients.Count
Set oRecipients = oMessage.Recipients
For iRecipient = 0 to qtyRecipients-1
WriteLog(oMessage.ID & " - To: " & oRecipients(iRecipient).Address)
Next
End Sub

'Sub OnDeliverMessage(oMessage)
'End Sub


Simpest way how to to reproduce it is to use Server Test Tool, set number of messages sent to 1 and add to To address something like "ěščřžžý@domain.com" according your test environment.

Chars with dicritical marks are correctly written to hMailServer native log (and I suppose without this script hMailServer handles such message without problems) problem is only with VBscript.

Another question is whether non-ASCII chars are allowed in e-mail address..

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

Post by martin » 2006-12-20 19:32

I tried to reproduce this, but was not immediately able to. Have you added ěščřžžý@domain.com as an account to hMailServer? Or are you using a catch-all address for the domain? Otherwise you should not get to the OnAcceptMessage-event at all.

I took that VBA script, pasted into my script file, reloaded the scipt. When I sent a message, I got an execution error in the script.

"ERROR" 2320 "2006-12-20 18:19:08.609" "Script Error: Source: Microsoft VBScript runtime error - Error: 800A0005 - Description: Invalid procedure call or argument - Line: 9 Column: 0 - Code: (null)"

The problem seems to occur when writing to the log file. Scripting.FileSystemObject doesn't seem to like those characters.

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

Post by tonda » 2006-12-20 19:50

I have no ERROR message in ERROR log file, service hMailServer simply terminates so I can only guess where problem is...

Thank you Martin, I will search in FSO documentation..

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

Post by martin » 2006-12-20 19:52

Perhaps you can simply try to uncomment the lines which does the logging to the file and see if it works then? I mean the lines where you access functions in FSO.

When you say that it hangs, what do you mean by that? Can you still access hMailServer Administrator?

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

Post by tonda » 2006-12-21 00:32

It it little bit complicated, because when I add line WriteLog("ěščřř") to the beginning of OnAcceptMessage procedure, string from parameter is correctly written to log file :shock: , so OFS is able to write characters with diacritical mark.

When recipient address contains diacritical marks - hmail service terminates unexpectedly and must be started again..

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

Post by martin » 2006-12-21 10:39

As I wrote, I tested with the same script and same address but didn't get this problem. So I need some more info to be able to reproduce it.

Can you send me a screenshot of your config from stress-tester at martin@hmailserver.com so that i can test with the exact same settings?
What hMailServer version are you using? And are you using any more scripts than the snippet you posted in your first post?

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

Post by tonda » 2006-12-29 23:43

This problem was finally solved thanks to the cooperation with Martin. When it is necessary to use FileSystemObject for writing some values (for example Subject of processed message) and it is possible that this value will contain characters with diacritical marks, it is necessary to open text file, used for log writes, in Unicode mode:

SET ofs = CreateObject("Scripting.FileSystemObject")
SET ofil = ofs.OpenTextFile(csLogFileName, 8, True, -1)

Last parameter -1 specifies TristateTrue mode (see VBScript help).

Without this parameter file is created and opened in ASCII mode and when string, written to this file using WriteLine, contains characters with diactritical marks, WriteLine fails with error "Invalid procedure call or argument."

Post Reply