* [pmg-devel] [PATCH pmg-api] fix #4211: convert quarantine link mail to template
@ 2024-10-01 12:59 Christoph Heiss
2024-10-03 15:26 ` Stoiko Ivanov
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Heiss @ 2024-10-01 12:59 UTC (permalink / raw)
To: pmg-devel
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,
only converted to HTML like all other templates.
[0] https://bugzilla.proxmox.com/show_bug.cgi?id=4211
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
src/Makefile | 1 +
src/PMG/API2/Quarantine.pm | 19 +++++++------------
src/templates/quarantine-link.tt | 14 ++++++++++++++
3 files changed, 22 insertions(+), 12 deletions(-)
create mode 100644 src/templates/quarantine-link.tt
diff --git a/src/Makefile b/src/Makefile
index 8e49a10..e268b05 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -44,6 +44,7 @@ TEMPLATES = \
postgresql.conf.in \
pg_hba.conf.in \
backup-notification.tt \
+ quarantine-link.tt \
TEMPLATES_FILES = $(addprefix templates/, ${TEMPLATES})
diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm
index 9301da9..59b4c9a 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.tt', $vars, $mailfrom, $receiver);
}
__PACKAGE__->register_method ({
diff --git a/src/templates/quarantine-link.tt b/src/templates/quarantine-link.tt
new file mode 100644
index 0000000..3cbba1c
--- /dev/null
+++ b/src/templates/quarantine-link.tt
@@ -0,0 +1,14 @@
+[%- SET title = "Proxmox Mail Gateway - Quarantine Link" -%]
+<html>
+ <head>
+ <title>[% title %]</title>
+ </head>
+ <body>
+ <p>
+ Here is your link for the spam quarantine on [% fqdn %]:<br/><br/>
+ <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.46.0
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pmg-devel] [PATCH pmg-api] fix #4211: convert quarantine link mail to template
2024-10-01 12:59 [pmg-devel] [PATCH pmg-api] fix #4211: convert quarantine link mail to template Christoph Heiss
@ 2024-10-03 15:26 ` Stoiko Ivanov
2024-10-04 8:34 ` Christoph Heiss
0 siblings, 1 reply; 3+ messages in thread
From: Stoiko Ivanov @ 2024-10-03 15:26 UTC (permalink / raw)
To: Christoph Heiss; +Cc: pmg-devel
thanks for addressing this issue!
the change sadly now makes the mail to only contain a text/html part, w/o
a text/plain alternative (just like the quarantine report sent out to
users - see [0,1]).
Would you be open/motivated to look into rendering the contents as
text/plain as well and adding them in finalize_report?
[0] https://bugzilla.proxmox.com/show_bug.cgi?id=1621
[1] https://bugzilla.proxmox.com/show_bug.cgi?id=4023
On Tue, 1 Oct 2024 14:59:43 +0200
Christoph Heiss <c.heiss@proxmox.com> wrote:
> 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,
> only converted to HTML like all other templates.
>
> [0] https://bugzilla.proxmox.com/show_bug.cgi?id=4211
>
> Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
> ---
> src/Makefile | 1 +
> src/PMG/API2/Quarantine.pm | 19 +++++++------------
> src/templates/quarantine-link.tt | 14 ++++++++++++++
> 3 files changed, 22 insertions(+), 12 deletions(-)
> create mode 100644 src/templates/quarantine-link.tt
>
> diff --git a/src/Makefile b/src/Makefile
> index 8e49a10..e268b05 100644
> --- a/src/Makefile
> +++ b/src/Makefile
> @@ -44,6 +44,7 @@ TEMPLATES = \
> postgresql.conf.in \
> pg_hba.conf.in \
> backup-notification.tt \
> + quarantine-link.tt \
>
> TEMPLATES_FILES = $(addprefix templates/, ${TEMPLATES})
>
> diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm
> index 9301da9..59b4c9a 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.tt', $vars, $mailfrom, $receiver);
> }
>
> __PACKAGE__->register_method ({
> diff --git a/src/templates/quarantine-link.tt b/src/templates/quarantine-link.tt
> new file mode 100644
> index 0000000..3cbba1c
> --- /dev/null
> +++ b/src/templates/quarantine-link.tt
> @@ -0,0 +1,14 @@
> +[%- SET title = "Proxmox Mail Gateway - Quarantine Link" -%]
> +<html>
> + <head>
> + <title>[% title %]</title>
> + </head>
> + <body>
> + <p>
> + Here is your link for the spam quarantine on [% fqdn %]:<br/><br/>
> + <a href="[% link | url %]">Spam quarantine</a>
> + </p>
> +
> + <p>Powered by <a target=_blank href='http://www.proxmox.com'>Proxmox</a>.</p>
> + </body>
> +</html>
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pmg-devel] [PATCH pmg-api] fix #4211: convert quarantine link mail to template
2024-10-03 15:26 ` Stoiko Ivanov
@ 2024-10-04 8:34 ` Christoph Heiss
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Heiss @ 2024-10-04 8:34 UTC (permalink / raw)
To: Stoiko Ivanov; +Cc: pmg-devel
On Thu, Oct 03, 2024 at 05:26:25PM GMT, Stoiko Ivanov wrote:
> thanks for addressing this issue!
>
> the change sadly now makes the mail to only contain a text/html part, w/o
> a text/plain alternative (just like the quarantine report sent out to
> users - see [0,1]).
Yeah, I've noticed that. But since all other templated emails were
HTML-only too, I just did go ahead with it.
>
> Would you be open/motivated to look into rendering the contents as
> text/plain as well and adding them in finalize_report?
Sure, I can look into it!
>
> [0] https://bugzilla.proxmox.com/show_bug.cgi?id=1621
> [1] https://bugzilla.proxmox.com/show_bug.cgi?id=4023
>
> On Tue, 1 Oct 2024 14:59:43 +0200
> Christoph Heiss <c.heiss@proxmox.com> wrote:
>
> > 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,
> > only converted to HTML like all other templates.
> >
> > [0] https://bugzilla.proxmox.com/show_bug.cgi?id=4211
> >
> > Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
> > ---
> > src/Makefile | 1 +
> > src/PMG/API2/Quarantine.pm | 19 +++++++------------
> > src/templates/quarantine-link.tt | 14 ++++++++++++++
> > 3 files changed, 22 insertions(+), 12 deletions(-)
> > create mode 100644 src/templates/quarantine-link.tt
> >
> > diff --git a/src/Makefile b/src/Makefile
> > index 8e49a10..e268b05 100644
> > --- a/src/Makefile
> > +++ b/src/Makefile
> > @@ -44,6 +44,7 @@ TEMPLATES = \
> > postgresql.conf.in \
> > pg_hba.conf.in \
> > backup-notification.tt \
> > + quarantine-link.tt \
> >
> > TEMPLATES_FILES = $(addprefix templates/, ${TEMPLATES})
> >
> > diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm
> > index 9301da9..59b4c9a 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.tt', $vars, $mailfrom, $receiver);
> > }
> >
> > __PACKAGE__->register_method ({
> > diff --git a/src/templates/quarantine-link.tt b/src/templates/quarantine-link.tt
> > new file mode 100644
> > index 0000000..3cbba1c
> > --- /dev/null
> > +++ b/src/templates/quarantine-link.tt
> > @@ -0,0 +1,14 @@
> > +[%- SET title = "Proxmox Mail Gateway - Quarantine Link" -%]
> > +<html>
> > + <head>
> > + <title>[% title %]</title>
> > + </head>
> > + <body>
> > + <p>
> > + Here is your link for the spam quarantine on [% fqdn %]:<br/><br/>
> > + <a href="[% link | url %]">Spam quarantine</a>
> > + </p>
> > +
> > + <p>Powered by <a target=_blank href='http://www.proxmox.com'>Proxmox</a>.</p>
> > + </body>
> > +</html>
>
_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-04 8:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-01 12:59 [pmg-devel] [PATCH pmg-api] fix #4211: convert quarantine link mail to template Christoph Heiss
2024-10-03 15:26 ` Stoiko Ivanov
2024-10-04 8:34 ` Christoph Heiss
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox