[SOLVED] Mail flow broken on 7.1.8 patch on specific case

AirForLife

Member
Mar 21, 2019
24
1
8
35
Hi,
After patching PMG to the latest 7.1.8 version, we have noticed that part of mail gets deferred and are stuck in the queues.

Nov 10 09:43:42 av1 pmg-smtp-filter[86341]: 40E3C636CABA52B679: SA score=6/5 time=9.554 bayes=undefined autolearn=disabled hits=DKIM_SIGNED(0.1),DKIM_VALID(-0.1),DKIM_VALID_AU(-0.1),DKIM_VALID_EF(-0.1),HTML_FONT_LOW_CONTRAST(0.001),HTML_MESSAGE(0.001),RCVD_IN_DNSWL_NONE(-0.0001),RCVD_IN_MSPIKE_H2(-0.001),SPF_HELO_NONE(0.001),SPF_PASS(-0.001),T_KAM_HTML_FONT_INVALID(0.01),URIBL_ABUSE_SURBL(1.948),URIBL_BLACK(5)
Nov 10 09:43:42 av1 pmg-smtp-filter[86341]: Wide character in syswrite at /usr/share/perl/5.32/Net/Cmd.pm line 210.
Nov 10 09:43:42 av1 pmg-smtp-filter[86341]: 40E3C636CABA52B679: reinject mail to <internaluser@domain.com> (rule: default-accept) failed
Nov 10 09:43:42 av1 pmg-smtp-filter[86341]: 40E3C636CABA52B679: processing time: 9.623 seconds (9.554, 0.031, 0)
Nov 10 09:43:42 av1 postfix/lmtp[86410]: 99E1F40D6B: to=<internaluser@domain.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=64842, delays=64816/17/0.05/9.6, dsn=4.4.0, status=deferred (host 127.0.0.1[127.0.0.1] said: 451 4.4.0 detected undelivered mail to <internaluser@domain.com> (in reply to end of DATA command))

We had no such problem with older 7.1.6 version.

Any fix/workaround ?
 
Last edited:
could you please provide:
* the complete log from this mail (most likely the tracking center should catch everything)
* the mail as .eml
* the output of `pmgdb dump` (to get an overview of your rules)

on a hunch I think it might be related to the following patch I sent yesterday:
https://lists.proxmox.com/pipermail/pmg-devel/2022-November/002144.html
(you can verify this by comparing if this happens when a Modify Field (header) action is invoked, on a mail with a non-ascii character in the field)
 
Last edited:
Looks like its related, mail gets deferred when header is modified by rule.
Tested with mail subject ąčęėįšųūž - it gets deferred and stuck if modified by rule.
Sent logs by email.
 
Looks like its related, mail gets deferred when header is modified by rule.
any chance you'd be willing to test the patch on your deployment? (this would help us to apply it faster, and get a better view if it fixes all the cases)

it's a one-line fix - so manually editing /usr/share/perl5/PMG/RuleDB/ModField.pm is probably the easiest.
afterwards you need to restart pmg-smtp-filter, and test again.

to go back to the stock version - simply reinstall pmg-api: `apt install --reinstall pmg-api`

Sent logs by email.
just to be sure - to s.ivanov _at_ proxmox.com?
 
any chance you'd be willing to test the patch on your deployment? (this would help us to apply it faster, and get a better view if it fixes all the cases)

it's a one-line fix - so manually editing /usr/share/perl5/PMG/RuleDB/ModField.pm is probably the easiest.
afterwards you need to restart pmg-smtp-filter, and test again.

to go back to the stock version - simply reinstall pmg-api: `apt install --reinstall pmg-api`


just to be sure - to s.ivanov _at_ proxmox.com?
Sure, can you provide what text to edit?

Yes, sent to your provided mail.
 
Sure, can you provide what text to edit?
the patch from the linked mailing-list post:
https://lists.proxmox.com/pipermail/pmg-devel/2022-November/002144.html

Code:
--- a/src/PMG/RuleDB/ModField.pm
+++ b/src/PMG/RuleDB/ModField.pm
@@ -4,6 +4,8 @@ use strict;
 use warnings;
 use DBI;
 use Digest::SHA;
+use Encode qw(encode decode);
+use MIME::Words qw(encode_mimewords);
 
 use PMG::Utils;
 use PMG::ModGroup;
@@ -107,7 +109,7 @@ sub execute {
 
     foreach my $ta (@$subgroups) {
     my ($tg, $e) = (@$ta[0], @$ta[1]);
-    $e->head->replace($self->{field}, $fvalue);
+    $e->head->replace($self->{field}, encode_mimewords(encode('UTF-8', $fvalue), "Charset" => "UTF-8"));
     }
 }

just edit /usr/share/perl5/PMG/RuleDB/ModField.pm
add the two lines on top
and change the line as indicated

Hope this explains it (else I can try to send you a patched version..)!
 
the patch from the linked mailing-list post:
https://lists.proxmox.com/pipermail/pmg-devel/2022-November/002144.html

Code:
--- a/src/PMG/RuleDB/ModField.pm
+++ b/src/PMG/RuleDB/ModField.pm
@@ -4,6 +4,8 @@ use strict;
 use warnings;
 use DBI;
 use Digest::SHA;
+use Encode qw(encode decode);
+use MIME::Words qw(encode_mimewords);
 
 use PMG::Utils;
 use PMG::ModGroup;
@@ -107,7 +109,7 @@ sub execute {
 
     foreach my $ta (@$subgroups) {
     my ($tg, $e) = (@$ta[0], @$ta[1]);
-    $e->head->replace($self->{field}, $fvalue);
+    $e->head->replace($self->{field}, encode_mimewords(encode('UTF-8', $fvalue), "Charset" => "UTF-8"));
     }
 }

just edit /usr/share/perl5/PMG/RuleDB/ModField.pm
add the two lines on top
and change the line as indicated

Hope this explains it (else I can try to send you a patched version..)!
That solved the problem, thanks!
 
That solved the problem, thanks!
glad to hear!
I assume that solves the mail-flow issue - not the applying patch question?

if yes - I'll try to get the patch applied soon.

Thanks for the report!
 
I am seeing similar issue in the logs but no messages stuck queue...

Code:
Nov 10 19:33:26 mx.example.com pmg-smtp-filter[1354]: 121503636D43F36F0B6: SA score=6/5 time=2.420 bayes=undefined autolearn=disabled hits=DKIMWL_WL_MED(-0.001),DKIM_SIGNED(0.1),DKIM_VALID(-0.25),HEADER_FROM_DIFFERENT_DOMAINS(0.25),HTML_MESSAGE(0.001),MIME_QP_LONG_LINE(0.5),RAZOR2_CF_RANGE_51_100(2.43),RAZOR2_CHECK(2.5),RCVD_IN_DNSWL_NONE(-0.0001),SPF_HELO_PASS(-0.001),SPF_PASS(-0.25),URIBL_GREY(1)
Nov 10 19:33:26 mx.example.com pmg-smtp-filter[1354]: 121503636D43F36F0B6: added disclaimer (rule: OverLevel2SenderWarning)
Nov 10 19:33:26 mx.example.com pmg-smtp-filter[1354]: 121503636D43F36F0B6: added disclaimer (rule: OverLevel2SenderWarning)
Nov 10 19:33:26 mx.example.com pmg-smtp-filter[1354]: Wide character at /usr/share/perl5/MIME/WordDecoder.pm line 616.
Nov 10 19:33:26 mx.example.com pmg-smtp-filter[1354]: fast exit because of errors (free 260993024 bytes)

I am guessing it's the same problem as above?
I will wait for patch...
 
Last edited:
I am guessing it's the same problem as above?
different errormessage - maybe a different issue - if possible please share:
* the complete logs of the mail
* the mail as .eml
* in this case probably more relevant - your rulesystem

thanks!
 
different errormessage - maybe a different issue - if possible please share:
* the complete logs of the mail
* the mail as .eml
* in this case probably more relevant - your rulesystem

thanks!
I have sent you what I can @Stoiko Ivanov via email. If you can give advice how to capture failing message I maybe can provide more info. I am having a hard time finding the message to replicate this issue with as messages that are failing are also not showing in the tracking center...
 
I have sent you what I can @Stoiko Ivanov via email. If you can give advice how to capture failing message I maybe can provide more info. I am having a hard time finding the message to replicate this issue with as messages that are failing are also not showing in the tracking center...
could you please try to install pmg-api 7.1-9 (available in pmgtest) ? - it contains a patch that should take care of the issue

Thanks!
 
  • Like
Reactions: poetry
could you please try to install pmg-api 7.1-9 (available in pmgtest) ? - it contains a patch that should take care of the issue

Thanks!
I can confirm that the patch fixes the issue. I don't see the errors anymore and messages are now parsing to tracking center.
Thank you very much for such a quick resolution! You are amazing!
 
  • Like
Reactions: Stoiko Ivanov
Thank you very much for such a quick resolution! You are amazing!
nothing to thank us for - I was working in that area of the code anyways :)
Thanks for testing the new version and confirming it fixes the issue!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!