[pmg-devel] [PATCH pmg-api v4 2/2] fix #4211: convert quarantine link mail to template
Stoiko Ivanov
s.ivanov at proxmox.com
Mon Oct 14 20:05:48 CEST 2024
From: Christoph Heiss <c.heiss at proxmox.com>
Fixes #4211 [0] by converting the currently hardcoded text for the
quarantine link mail to a proper template, enabling users to write their
own versions.
Pretty straight-forward change. The overall content/wording is kept
pretty much for the plain-text version, the HTML variant is adapted from
that as needed.
[0] https://bugzilla.proxmox.com/show_bug.cgi?id=4211
Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
[S.I. adapt to changed arguments of finalize_report]
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
src/Makefile | 2 ++
src/PMG/API2/Quarantine.pm | 19 +++++++------------
src/templates/quarantine-link.plain.tt | 6 ++++++
src/templates/quarantine-link.tt | 13 +++++++++++++
4 files changed, 28 insertions(+), 12 deletions(-)
create mode 100644 src/templates/quarantine-link.plain.tt
create mode 100644 src/templates/quarantine-link.tt
diff --git a/src/Makefile b/src/Makefile
index 8e49a10..1232880 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -44,6 +44,8 @@ TEMPLATES = \
postgresql.conf.in \
pg_hba.conf.in \
backup-notification.tt \
+ quarantine-link.tt \
+ quarantine-link.plain.tt \
TEMPLATES_FILES = $(addprefix templates/, ${TEMPLATES})
diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm
index 9301da9..16dec57 100644
--- a/src/PMG/API2/Quarantine.pm
+++ b/src/PMG/API2/Quarantine.pm
@@ -1235,18 +1235,13 @@ my sub send_link_mail {
my $esc_ticket = uri_escape($ticket);
my $link = "$protocol_fqdn_port/quarantine?ticket=${esc_ticket}";
- my $text = "Here is your Link for the Spam Quarantine on $fqdn:\n\n$link\n";
-
- my $mail = MIME::Entity->build(
- Type => "text/plain",
- To => $receiver,
- From => $mailfrom,
- Subject => "Proxmox Mail Gateway - Quarantine Link",
- Data => $text,
- );
-
- # we use an empty envelope sender (we don't want to receive NDRs)
- PMG::Utils::reinject_local_mail ($mail, '', [$receiver], undef, $fqdn);
+ my $tt = PMG::Config::get_template_toolkit();
+ my $vars = {
+ fqdn => $fqdn,
+ link => $link,
+ };
+
+ PMG::Utils::finalize_report($tt, 'quarantine-link', $vars, $mailfrom, $receiver);
}
__PACKAGE__->register_method ({
diff --git a/src/templates/quarantine-link.plain.tt b/src/templates/quarantine-link.plain.tt
new file mode 100644
index 0000000..bb04e67
--- /dev/null
+++ b/src/templates/quarantine-link.plain.tt
@@ -0,0 +1,6 @@
+subject: Proxmox Mail Gateway - Quarantine Link
+Here is your link for the spam quarantine on [% fqdn %]:
+
+[% link %]
+
+Powered by http://www.proxmox.com
diff --git a/src/templates/quarantine-link.tt b/src/templates/quarantine-link.tt
new file mode 100644
index 0000000..d6fd17e
--- /dev/null
+++ b/src/templates/quarantine-link.tt
@@ -0,0 +1,13 @@
+[%- SET title = "Proxmox Mail Gateway - Quarantine Link" -%]
+<html>
+ <head>
+ <title>[% title %]</title>
+ </head>
+ <body>
+ <p>
+ Here is your link for the spam quarantine on <code>[% fqdn %]</code>: <a href='[% link | url %]'>Spam quarantine</a>
+ </p>
+
+ <p>Powered by <a target=_blank href='http://www.proxmox.com'>Proxmox</a>.</p>
+ </body>
+</html>
--
2.39.5
More information about the pmg-devel
mailing list