Normally mail server returns 2 lines after opening the socket. The first line contains the state and host name.
if mail server returns 3 lines after opening the socket:
"220-hostname.domain"
"220"
""
the readhandler procedure fails to handle the response and the program returns without correct error handling leaving log file open.
The readhandler loop where the response lines are handled skips the first line:
IF SUBSTRING(cThisLine,4,1,"CHARACTER") = "-" THEN NEXT RESPLINECOUNT.
When handling the next line SUBSTRING returns error as the length of cThisLine is only 3.
We fixed this by adding check on the length:
IF LENGTH(cThisLine) > 3 AND SUBSTRING(cThisLine,4,1,"CHARACTER") = "-" THEN NEXT RESPLINECOUNT.
Additionally, the next handling does not work, as the str variable holds the whole response.
ELSE v = INTEGER(ENTRY(1,str,"-")) NO-ERROR .
The variable cThisLine should be used with this statement.
ELSE v = INTEGER(ENTRY(1,cThisLine,"-")) NO-ERROR .
Here is how we fixed this block to our own use:
IF LENGTH(cThisLine) > 3 AND
SUBSTRING (cThisLine,4,1,"CHARACTER") = "-"
THEN NEXT RESPLINECOUNT.
IF L_DoAUTH AND (vState = 2) THEN
v = INTEGER(ENTRY(1,cThisLine,"-")) NO-ERROR .
ELSE v = INTEGER(ENTRY(1,cThisLine," ")) NO-ERROR .
I'm not sure how the second line of the response is built when using authentication. We resolved our problem with this fix.
pekka.vanninen@digia.com