* [pmg-devel] [PATCH pmg-api 0/3] adds plain-text variants for both reports
@ 2025-09-18 10:30 Hannes Laimer
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Hannes Laimer @ 2025-09-18 10:30 UTC (permalink / raw)
To: pmg-devel
This addresses both #1621 and #4023. The plain-text parts are a little
"spacey", but overall I think the formatting is fine.
https://bugzilla.proxmox.com/show_bug.cgi?id=4023
https://bugzilla.proxmox.com/show_bug.cgi?id=1621
Hannes Laimer (3):
pmgqm: add plain subject/from fields for reports
fix #1621: templates: add plain-text variant of short/verbose spam
report
fix #4023: templates: add plain-text variant of admin report
src/Makefile | 3 ++
src/PMG/CLI/pmgqm.pm | 17 ++++++--
src/templates/pmgreport.plain.tt | 51 +++++++++++++++++++++++
src/templates/spamreport-short.plain.tt | 21 ++++++++++
src/templates/spamreport-verbose.plain.tt | 25 +++++++++++
5 files changed, 113 insertions(+), 4 deletions(-)
create mode 100644 src/templates/pmgreport.plain.tt
create mode 100644 src/templates/spamreport-short.plain.tt
create mode 100644 src/templates/spamreport-verbose.plain.tt
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pmg-devel] [PATCH pmg-api 1/3] pmgqm: add plain subject/from fields for reports
2025-09-18 10:30 [pmg-devel] [PATCH pmg-api 0/3] adds plain-text variants for both reports Hannes Laimer
@ 2025-09-18 10:30 ` Hannes Laimer
2025-09-18 13:21 ` Thomas Lamprecht
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report Hannes Laimer
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Hannes Laimer @ 2025-09-18 10:30 UTC (permalink / raw)
To: pmg-devel
We don't want plain-text reports to contain HTML-escaped chars,
this skips html encoding for the plain-text part.
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/PMG/CLI/pmgqm.pm | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm
index 41f9f1a..acac284 100755
--- a/src/PMG/CLI/pmgqm.pm
+++ b/src/PMG/CLI/pmgqm.pm
@@ -45,17 +45,26 @@ sub get_item_data {
$item->{id} = sprintf("C%dR%dT%d", $ref->{cid}, $ref->{rid}, $ref->{ticketid});
- $item->{subject} =
- PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('subject')) || 'No Subject');
+ my $raw_subject = PVE::Tools::trim($head->get('subject')) || 'No Subject';
+ $item->{subject} = PMG::Utils::rfc1522_to_html($raw_subject);
+ $item->{subject_plain} = PMG::Utils::decode_rfc1522($raw_subject);
- my $from = PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('from') // $ref->{sender}));
- my $sender = PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('sender')));
+ my $raw_from = PVE::Tools::trim($head->get('from') // $ref->{sender});
+ my $raw_sender = PVE::Tools::trim($head->get('sender'));
+
+ my $from = PMG::Utils::rfc1522_to_html($raw_from);
+ my $sender = PMG::Utils::rfc1522_to_html($raw_sender);
+
+ my $from_plain = PMG::Utils::decode_rfc1522($raw_from);
+ my $sender_plain = PMG::Utils::decode_rfc1522($raw_sender);
if ($sender) {
$item->{sender} = $sender;
$item->{from} = sprintf("%s on behalf of %s", $sender, $from);
+ $item->{from_plain} = sprintf("%s on behalf of %s", $sender_plain, $from_plain);
} else {
$item->{from} = $from;
+ $item->{from_plain} = $from_plain;
}
$item->{envelope_sender} = $ref->{sender};
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pmg-devel] [PATCH pmg-api 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report
2025-09-18 10:30 [pmg-devel] [PATCH pmg-api 0/3] adds plain-text variants for both reports Hannes Laimer
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
@ 2025-09-18 10:30 ` Hannes Laimer
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 3/3] fix #4023: templates: add plain-text variant of admin report Hannes Laimer
2025-09-18 14:33 ` [pmg-devel] superseded: [PATCH pmg-api 0/3] adds plain-text variants for both reports Hannes Laimer
3 siblings, 0 replies; 7+ messages in thread
From: Hannes Laimer @ 2025-09-18 10:30 UTC (permalink / raw)
To: pmg-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/Makefile | 2 ++
src/templates/spamreport-short.plain.tt | 21 +++++++++++++++++++
src/templates/spamreport-verbose.plain.tt | 25 +++++++++++++++++++++++
3 files changed, 48 insertions(+)
create mode 100644 src/templates/spamreport-short.plain.tt
create mode 100644 src/templates/spamreport-verbose.plain.tt
diff --git a/src/Makefile b/src/Makefile
index 896319b..b75c818 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -27,7 +27,9 @@ TEMPLATES = \
fetchmailrc.tt \
pmgreport.tt \
spamreport-verbose.tt \
+ spamreport-verbose.plain.tt \
spamreport-short.tt \
+ spamreport-short.plain.tt \
main.cf.in \
main.cf.in.demo \
master.cf.in \
diff --git a/src/templates/spamreport-short.plain.tt b/src/templates/spamreport-short.plain.tt
new file mode 100644
index 0000000..b79ee04
--- /dev/null
+++ b/src/templates/spamreport-short.plain.tt
@@ -0,0 +1,21 @@
+[% IF timespan == 'week' -%]
+[% SET title = "Weekly Spam Report for '${pmail}' - ${date}'" -%]
+[% ELSIF timespan.substr(timespan.length - 1) == 'h' -%]
+[% SET title = "Spam Report (last ${timespan}) for '${pmail}' - ${date}" -%]
+[% ELSE -%]
+[% SET title = "Daily Spam Report for '${pmail}' - ${date}" -%]
+[% END -%]
+
+subject: [% title %]
+
+You received [% mailcount %] spam mail(s).
+
+[% SET links = [] %]
+Manage your spam quarantine: [% n = links.size + 1; links.push(managehref); %][[% n %]]
+Powered by Proxmox: [% n = links.size + 1; links.push('http://www.proxmox.com'); %][[% n %]]
+
+Links:
+[% FOREACH l IN links %][% loop.index + 1 %]: [% l %]
+[% END %]
+
+
diff --git a/src/templates/spamreport-verbose.plain.tt b/src/templates/spamreport-verbose.plain.tt
new file mode 100644
index 0000000..641eb03
--- /dev/null
+++ b/src/templates/spamreport-verbose.plain.tt
@@ -0,0 +1,25 @@
+[%- IF timespan == 'week' -%]
+[%- SET title = "Weekly Spam Report for '${pmail}' - ${date}'" -%]
+[%- ELSIF timespan.substr(timespan.length - 1) == 'h' -%]
+[%- SET title = "Spam Report (last ${timespan}) for '${pmail}' - ${date}" -%]
+[%- ELSE -%]
+[%- SET title = "Daily Spam Report for '${pmail}' - ${date}" -%]
+[%- END -%]
+subject: [% title %]
+[% SET links = [] -%]
+[% IF items.size -%]
+Spam quarantine entries for [% pmail %]:
+
+[% FOREACH item IN items %]
+- [% item.date %] [% item.time %] From: [% item.from_plain %]
+ Subject: [% item.subject_plain %] [% n = links.size + 1; links.push(item.href); %][[% n %]]
+
+[% END %]
+[% ELSE %]
+No spam entries for the selected period.
+[% END %]
+Manage your spam quarantine: [% n = links.size + 1; links.push(managehref); %][[% n %]]
+Powered by Proxmox: [% n = links.size + 1; links.push('http://www.proxmox.com'); %][[% n %]]
+Links:
+[% FOREACH l IN links %][% loop.index + 1 %]: [% l %]
+[% END %]
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pmg-devel] [PATCH pmg-api 3/3] fix #4023: templates: add plain-text variant of admin report
2025-09-18 10:30 [pmg-devel] [PATCH pmg-api 0/3] adds plain-text variants for both reports Hannes Laimer
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report Hannes Laimer
@ 2025-09-18 10:30 ` Hannes Laimer
2025-09-18 14:33 ` [pmg-devel] superseded: [PATCH pmg-api 0/3] adds plain-text variants for both reports Hannes Laimer
3 siblings, 0 replies; 7+ messages in thread
From: Hannes Laimer @ 2025-09-18 10:30 UTC (permalink / raw)
To: pmg-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/Makefile | 1 +
src/templates/pmgreport.plain.tt | 51 ++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
create mode 100644 src/templates/pmgreport.plain.tt
diff --git a/src/Makefile b/src/Makefile
index b75c818..2c5ef28 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -26,6 +26,7 @@ CONF_MANS= pmg.conf.5 cluster.conf.5
TEMPLATES = \
fetchmailrc.tt \
pmgreport.tt \
+ pmgreport.plain.tt \
spamreport-verbose.tt \
spamreport-verbose.plain.tt \
spamreport-short.tt \
diff --git a/src/templates/pmgreport.plain.tt b/src/templates/pmgreport.plain.tt
new file mode 100644
index 0000000..a46d20e
--- /dev/null
+++ b/src/templates/pmgreport.plain.tt
@@ -0,0 +1,51 @@
+subject: Proxmox Status Report - [% date %] ([% fqdn %])
+[% IF cluster -%]
+Cluster Status
+[% FOREACH item IN cluster -%]
+- Hostname: [% item.hostname %]
+ IP Address: [% item.ip %]
+ Role: [% item.type %]
+ State: [% item.state %]
+ Load: [% item.loadavg1 %]
+ Memory: [% item.memory %]
+ Disk: [% item.disk %]
+[% IF !loop.last %]----
+[% END %]
+[% END %]
+[% END %]
+[% IF system -%]
+System Status
+[% FOREACH item IN system -%]
+- [% item.text %]: [% item.value %]
+[% END %]
+[% END %]
+[% IF incoming -%]
+Incoming Mails (24 hours)
+[% FOREACH item IN incoming -%]
+- [% item.text %][% IF item.percentage.defined %] ([% item.percentage %]%)[% END %]: [% item.value %]
+[% END %]
+[% END %]
+[% IF outgoing -%]
+Outgoing Mails (24 hours)
+[% FOREACH item IN outgoing -%]
+- [% item.text %][% IF item.percentage.defined %] ([% item.percentage %]%)[% END %]: [% item.value %]
+[% END %]
+[% END %]
+[% IF virusstat -%]
+Virus Charts (Top 10)
+[% FOREACH item IN virusstat -%]
+- [% item.name %]: [% item.count %]
+[% END %]
+[% END %]
+[% IF virusquar -%]
+Virus Quarantine
+[% FOREACH item IN virusquar -%]
+- [% item.text %]: [% item.value %]
+[% END %]
+[% END %]
+[% IF spamquar -%]
+Spam Quarantine
+[% FOREACH item IN spamquar -%]
+- [% item.text %]: [% item.value %]
+[% END %]
+[% END %]
--
2.47.3
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [pmg-devel] [PATCH pmg-api 1/3] pmgqm: add plain subject/from fields for reports
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
@ 2025-09-18 13:21 ` Thomas Lamprecht
2025-09-18 14:08 ` Hannes Laimer
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Lamprecht @ 2025-09-18 13:21 UTC (permalink / raw)
To: Hannes Laimer, pmg-devel
Am 18.09.25 um 12:31 schrieb Hannes Laimer:
> We don't want plain-text reports to contain HTML-escaped chars,
> this skips html encoding for the plain-text part.
>
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> src/PMG/CLI/pmgqm.pm | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm
> index 41f9f1a..acac284 100755
> --- a/src/PMG/CLI/pmgqm.pm
> +++ b/src/PMG/CLI/pmgqm.pm
> @@ -45,17 +45,26 @@ sub get_item_data {
>
> $item->{id} = sprintf("C%dR%dT%d", $ref->{cid}, $ref->{rid}, $ref->{ticketid});
>
> - $item->{subject} =
> - PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('subject')) || 'No Subject');
> + my $raw_subject = PVE::Tools::trim($head->get('subject')) || 'No Subject';
> + $item->{subject} = PMG::Utils::rfc1522_to_html($raw_subject);
> + $item->{subject_plain} = PMG::Utils::decode_rfc1522($raw_subject);
Not sure as I did not check in depth, but should the result from decode_rfc1522
above also get encoded as UTF-8 to avoid issues with odd characters?
>
> - my $from = PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('from') // $ref->{sender}));
> - my $sender = PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('sender')));
> + my $raw_from = PVE::Tools::trim($head->get('from') // $ref->{sender});
> + my $raw_sender = PVE::Tools::trim($head->get('sender'));
> +
> + my $from = PMG::Utils::rfc1522_to_html($raw_from);
> + my $sender = PMG::Utils::rfc1522_to_html($raw_sender);
> +
> + my $from_plain = PMG::Utils::decode_rfc1522($raw_from);
> + my $sender_plain = PMG::Utils::decode_rfc1522($raw_sender);
same here I think.
>
> if ($sender) {
> $item->{sender} = $sender;
> $item->{from} = sprintf("%s on behalf of %s", $sender, $from);
> + $item->{from_plain} = sprintf("%s on behalf of %s", $sender_plain, $from_plain);
> } else {
> $item->{from} = $from;
> + $item->{from_plain} = $from_plain;
> }
>
> $item->{envelope_sender} = $ref->{sender};
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [pmg-devel] [PATCH pmg-api 1/3] pmgqm: add plain subject/from fields for reports
2025-09-18 13:21 ` Thomas Lamprecht
@ 2025-09-18 14:08 ` Hannes Laimer
0 siblings, 0 replies; 7+ messages in thread
From: Hannes Laimer @ 2025-09-18 14:08 UTC (permalink / raw)
To: Thomas Lamprecht, pmg-devel
On 18.09.25 15:21, Thomas Lamprecht wrote:
> Am 18.09.25 um 12:31 schrieb Hannes Laimer:
>> We don't want plain-text reports to contain HTML-escaped chars,
>> this skips html encoding for the plain-text part.
>>
>> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
>> ---
>> src/PMG/CLI/pmgqm.pm | 17 +++++++++++++----
>> 1 file changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm
>> index 41f9f1a..acac284 100755
>> --- a/src/PMG/CLI/pmgqm.pm
>> +++ b/src/PMG/CLI/pmgqm.pm
>> @@ -45,17 +45,26 @@ sub get_item_data {
>>
>> $item->{id} = sprintf("C%dR%dT%d", $ref->{cid}, $ref->{rid}, $ref->{ticketid});
>>
>> - $item->{subject} =
>> - PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('subject')) || 'No Subject');
>> + my $raw_subject = PVE::Tools::trim($head->get('subject')) || 'No Subject';
>> + $item->{subject} = PMG::Utils::rfc1522_to_html($raw_subject);
>> + $item->{subject_plain} = PMG::Utils::decode_rfc1522($raw_subject);
>
> Not sure as I did not check in depth, but should the result from decode_rfc1522
> above also get encoded as UTF-8 to avoid issues with odd characters?
>
did some digging, and yes, that seems to be the problem.
```
# assume enc contains utf-8 and mime-encoded data returns a perl-string
(with wide characters)
sub decode_rfc1522 {
...
```
the template does not like getting `wide characters`, a
`Encode::encode('UTF-8', $plaintext)`
solves the problem. `rfc1522_to_html` already does basically this, and
`decode_rfc1522` does not. I'll fix that and send a v2.
Thanks for testing!
>>
>> - my $from = PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('from') // $ref->{sender}));
>> - my $sender = PMG::Utils::rfc1522_to_html(PVE::Tools::trim($head->get('sender')));
>> + my $raw_from = PVE::Tools::trim($head->get('from') // $ref->{sender});
>> + my $raw_sender = PVE::Tools::trim($head->get('sender'));
>> +
>> + my $from = PMG::Utils::rfc1522_to_html($raw_from);
>> + my $sender = PMG::Utils::rfc1522_to_html($raw_sender);
>> +
>> + my $from_plain = PMG::Utils::decode_rfc1522($raw_from);
>> + my $sender_plain = PMG::Utils::decode_rfc1522($raw_sender);
>
> same here I think.
>
>>
>> if ($sender) {
>> $item->{sender} = $sender;
>> $item->{from} = sprintf("%s on behalf of %s", $sender, $from);
>> + $item->{from_plain} = sprintf("%s on behalf of %s", $sender_plain, $from_plain);
>> } else {
>> $item->{from} = $from;
>> + $item->{from_plain} = $from_plain;
>> }
>>
>> $item->{envelope_sender} = $ref->{sender};
>
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pmg-devel] superseded: [PATCH pmg-api 0/3] adds plain-text variants for both reports
2025-09-18 10:30 [pmg-devel] [PATCH pmg-api 0/3] adds plain-text variants for both reports Hannes Laimer
` (2 preceding siblings ...)
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 3/3] fix #4023: templates: add plain-text variant of admin report Hannes Laimer
@ 2025-09-18 14:33 ` Hannes Laimer
3 siblings, 0 replies; 7+ messages in thread
From: Hannes Laimer @ 2025-09-18 14:33 UTC (permalink / raw)
To: pmg-devel
superseded-by:
https://lore.proxmox.com/pmg-devel/20250918143142.248758-1-h.laimer@proxmox.com/T/#t
On 18.09.25 12:31, Hannes Laimer wrote:
> This addresses both #1621 and #4023. The plain-text parts are a little
> "spacey", but overall I think the formatting is fine.
>
> https://bugzilla.proxmox.com/show_bug.cgi?id=4023
> https://bugzilla.proxmox.com/show_bug.cgi?id=1621
>
> Hannes Laimer (3):
> pmgqm: add plain subject/from fields for reports
> fix #1621: templates: add plain-text variant of short/verbose spam
> report
> fix #4023: templates: add plain-text variant of admin report
>
> src/Makefile | 3 ++
> src/PMG/CLI/pmgqm.pm | 17 ++++++--
> src/templates/pmgreport.plain.tt | 51 +++++++++++++++++++++++
> src/templates/spamreport-short.plain.tt | 21 ++++++++++
> src/templates/spamreport-verbose.plain.tt | 25 +++++++++++
> 5 files changed, 113 insertions(+), 4 deletions(-)
> create mode 100644 src/templates/pmgreport.plain.tt
> create mode 100644 src/templates/spamreport-short.plain.tt
> create mode 100644 src/templates/spamreport-verbose.plain.tt
>
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-09-18 14:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-18 10:30 [pmg-devel] [PATCH pmg-api 0/3] adds plain-text variants for both reports Hannes Laimer
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 1/3] pmgqm: add plain subject/from fields for reports Hannes Laimer
2025-09-18 13:21 ` Thomas Lamprecht
2025-09-18 14:08 ` Hannes Laimer
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 2/3] fix #1621: templates: add plain-text variant of short/verbose spam report Hannes Laimer
2025-09-18 10:30 ` [pmg-devel] [PATCH pmg-api 3/3] fix #4023: templates: add plain-text variant of admin report Hannes Laimer
2025-09-18 14:33 ` [pmg-devel] superseded: [PATCH pmg-api 0/3] adds plain-text variants for both reports Hannes Laimer
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.