[pmg-devel] [PATCH pmg-api 2/2] local generated mail: add Auto-Submitted header
Stoiko Ivanov
s.ivanov at proxmox.com
Mon Mar 10 19:06:12 CET 2025
following the implementation in the proxmox-sendmail crate:
bcdcb181 ("fix #4162: sys: added `auto-submitted` header to email body")
this patch adds Auto-Submitted headers to the mail generated by PMG
(notifications, reports, bounces). reports and notifications get a
'auto-generated' value set, while bounces 'auto-replied'. The latter
is following postfix' bounces.
see https://www.rfc-editor.org/rfc/rfc3834.html and
https://bugzilla.proxmox.com/show_bug.cgi?id=4162
the header is added after MIME::Entity->build(), because this has a
list of allowed headers that are accepted as arguments:
https://metacpan.org/pod/MIME::Entity#Construction
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
src/PMG/RuleDB/Notify.pm | 2 ++
src/PMG/SMTP.pm | 2 ++
src/PMG/Utils.pm | 3 +++
3 files changed, 7 insertions(+)
diff --git a/src/PMG/RuleDB/Notify.pm b/src/PMG/RuleDB/Notify.pm
index b74675b..1ed1a20 100644
--- a/src/PMG/RuleDB/Notify.pm
+++ b/src/PMG/RuleDB/Notify.pm
@@ -244,6 +244,8 @@ sub execute {
Type => "message/rfc822",);
}
+ $top->head()->add('Auto-Submitted', 'auto-generated');
+
if ($msginfo->{testmode}) {
my $fh = $msginfo->{test_fh};
print $fh "notify: $self->{to}\n";
diff --git a/src/PMG/SMTP.pm b/src/PMG/SMTP.pm
index 77a707a..3fcfea2 100644
--- a/src/PMG/SMTP.pm
+++ b/src/PMG/SMTP.pm
@@ -290,6 +290,8 @@ EOF
Date => strftime("%a, %d %b %Y %T %z", localtime()),
Subject => 'Undelivered Mail');
+ $ndr->head()->add('Auto-Submitted', 'auto-replied');
+
$ndr->attach(
Data => $ndr_text,
Type => 'text/plain; charset=utf-8',
diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm
index ab0e6ac..d4d2b87 100644
--- a/src/PMG/Utils.pm
+++ b/src/PMG/Utils.pm
@@ -1328,6 +1328,9 @@ sub finalize_report {
Type => 'text/plain; charset=utf-8',
Encoding => '8-bit');
}
+
+ $top->head()->add('Auto-Submitted', 'auto-generated');
+
if ($debug) {
$top->print();
return;
--
2.39.5
More information about the pmg-devel
mailing list