all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api 2/2] local generated mail: add Auto-Submitted header
Date: Mon, 10 Mar 2025 19:06:12 +0100	[thread overview]
Message-ID: <20250310180612.21877-3-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20250310180612.21877-1-s.ivanov@proxmox.com>

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@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



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


  parent reply	other threads:[~2025-03-10 18:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-10 18:06 [pmg-devel] [PATCH pmg-api 0/2] add Date and Auto-Submitted headers to reports, bounces, notifications Stoiko Ivanov
2025-03-10 18:06 ` [pmg-devel] [PATCH pmg-api 1/2] dkim: local mail: add Date header Stoiko Ivanov
2025-03-10 18:06 ` Stoiko Ivanov [this message]
2025-07-29 13:53 ` [pmg-devel] applied: [PATCH pmg-api 0/2] add Date and Auto-Submitted headers to reports, bounces, notifications Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250310180612.21877-3-s.ivanov@proxmox.com \
    --to=s.ivanov@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal