Proxmox Mail Gateway – Wide character in syswrite

To fight spam we are using Proxmox Mail Gateway 7.1-8.
Today (after update?) we have found full queue of undelevered mails and strange errors in the maillog:

Nov  8 08:26:53 as postfix/lmtp[204578]: A56F8A2BB5: to=<>, relay=[]:10024, delay=1.2, delays=0.01/0/0.05/1.2, dsn=4.4.0, status=deferred (host[] said: 451 4.4.0 detected undelivered mail to <> (in reply to end of DATA command))

Nov  8 20:09:47 as pmg-smtp-filter[1196]: Wide character in syswrite at /usr/share/perl/5.32/Net/ line 210.

Nov  8 08:26:53 as pmg-smtp-filter[204435]: C0B4B636A04BCB4317: reinject mail to <> (rule: default-accept) failed

After some searching and editing files I came at the line 210 in and there was:

my $w = syswrite($cmd, $line, $len, $offset);

It occured to me that the $line must be in some unaccepted format so this syswrite fails.

I’ve installed Unicode::UTF8 with: apt install libunicode-utf8-perl

Edited and added above line 210:

  use utf8;
  use Unicode::UTF8 qw( encode_utf8 );

  while ($len) {
    my $wout;
    my $nfound = select(undef, $wout = $win, undef, $pending);
    if ((defined $nfound and $nfound > 0) or -f $cmd)    # -f for testing on win32
        $line = encode_utf8($line);
      my $w = syswrite($cmd, $line, $len, $offset);
      if (! defined($w) ) {

Then restarted pmg-smtp-filter and flushed the postfix queue.

# systemctl restart pmg-smtp-filter.service
# postqueue -f

The workaround works for now. Relieved!