[pmg-devel] [PATCH pmg-api 1/2] dkim: local mail: add Date header

Stoiko Ivanov s.ivanov at proxmox.com
Mon Mar 10 19:06:11 CET 2025


The DKIM signing of locally generated mail introduced in
cd011e2 ("reinject_local_mail: sign mails with DKIM based on header")
does not cover the date-header, since it is not added by our stack,
but by postfix/cleanup(8). This trips certain software (e.g.
Thunderbird), and covering 'Date' by the signature is 'highly advised'
by the DKIM-rfc:
https://datatracker.ietf.org/doc/html/rfc6376#section-5.4

Reported in our community forum:
https://forum.proxmox.com/threads/142465/page-2

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         | 1 +
 3 files changed, 5 insertions(+)

diff --git a/src/PMG/RuleDB/Notify.pm b/src/PMG/RuleDB/Notify.pm
index 95d2ffa..b74675b 100644
--- a/src/PMG/RuleDB/Notify.pm
+++ b/src/PMG/RuleDB/Notify.pm
@@ -8,6 +8,7 @@ use MIME::Head;
 use MIME::Entity;
 use MIME::Words qw(encode_mimewords);
 use Encode qw(decode encode);
+use POSIX qw(strftime);
 
 use PVE::SafeSyslog;
 
@@ -230,6 +231,7 @@ sub execute {
 	From    => $from_header,
 	To      => $to,
 	Subject => encode_mimewords(encode('UTF-8', $subject), "Charset" => "UTF-8"),
+	Date    => strftime("%a, %d %b %Y %T %z", localtime()),
 	Data => encode('UTF-8', $body));
 
     if ($self->{attach} eq 'O') {
diff --git a/src/PMG/SMTP.pm b/src/PMG/SMTP.pm
index 15c8464..77a707a 100644
--- a/src/PMG/SMTP.pm
+++ b/src/PMG/SMTP.pm
@@ -5,6 +5,7 @@ use warnings;
 use IO::Socket;
 use Encode;
 use MIME::Entity;
+use POSIX qw(strftime);
 
 use PVE::SafeSyslog;
 
@@ -286,6 +287,7 @@ EOF
 	Type => 'multipart/report; report-type=delivery-status;',
 	To => $sender,
 	From => $from_header,
+	Date => strftime("%a, %d %b %Y %T %z", localtime()),
 	Subject => 'Undelivered Mail');
 
     $ndr->attach(
diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm
index 3e7adbb..ab0e6ac 100644
--- a/src/PMG/Utils.pm
+++ b/src/PMG/Utils.pm
@@ -1313,6 +1313,7 @@ sub finalize_report {
 	Type    => ($html && $plaintext) ? 'multipart/alternative' : 'multipart/related',
 	To      => $data->{pmail_raw},
 	From    => $mailfrom,
+	Date    => strftime("%a, %d %b %Y %T %z", localtime()),
 	Subject => bencode_header(decode_entities($title)));
 
     if ($html) {
-- 
2.39.5





More information about the pmg-devel mailing list