From 3effdd6ef064a1bc8457d7f99915275448c684f4 Mon Sep 17 00:00:00 2001 From: Milan Date: Sun, 23 Apr 2023 12:15:18 +0200 Subject: [PATCH] mail.pm: replace MIME::Lite by Email::Sender * mail.pm uses Email:sender to use correct encoding on sending utf-8 encoded emails * notify-events.cgi now uses mail.pm. --- install/INSTALL.md | 4 +--- lib/calcms/mail.pm | 26 +++++++++++++----------- website/agenda/planung/notify-events.cgi | 23 +++++---------------- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/install/INSTALL.md b/install/INSTALL.md index c9ed5cb..21bc1a7 100644 --- a/install/INSTALL.md +++ b/install/INSTALL.md @@ -85,14 +85,13 @@ apt-get install libdate-manip-perl libdbi-perl libdbd-mysql-perl + libemail-sender-perl libencode-perl libjson-perl libhtml-formattext-withlinks-andtables-perl libhtml-parser-perl libhtml-template-perl libhtml-template-compiled-perl - libmime-base64-urlsafe-perl - libmime-lite-perl libsession-token-perl libtext-multimarkdown-perl libtext-wikicreole-perl @@ -132,7 +131,6 @@ apt-get install Image::Magick Image::Magick::Square JSON - MIME::Lite ModPerl::Util Session::Token Text::Diff::FormatedHtml diff --git a/lib/calcms/mail.pm b/lib/calcms/mail.pm index 8fb4309..9b271f1 100644 --- a/lib/calcms/mail.pm +++ b/lib/calcms/mail.pm @@ -4,22 +4,24 @@ use strict; use warnings; no warnings 'redefine'; -use MIME::Lite(); +use Email::Sender::Simple(); +use Email::Simple(); sub send($) { - my $mail = shift; + my ($mail) = @_; - my $msg = MIME::Lite->new( - 'From' => $mail->{'From'}, - 'To' => $mail->{'To'}, - 'Cc' => $mail->{'Cc'}, - 'Reply-To' => $mail->{'Reply-To'}, - 'Subject' => $mail->{'Subject'}, - 'Data' => $mail->{'Data'}, + my $email = Email::Simple->create( + 'Content-Type' => 'text/plain; charset=utf-8', + header => [ + 'From' => $mail->{'From'}, + 'To' => $mail->{'To'}, + 'Cc' => $mail->{'Cc'}, + 'Reply-To' => $mail->{'Reply-To'}, + 'Subject' => $mail->{'Subject'} + ], + body => $mail->{'Data'}, ); - - $msg->print( \*STDERR ); - $msg->send; + Email::Sender::Simple->send($email); } # do not delete next line diff --git a/website/agenda/planung/notify-events.cgi b/website/agenda/planung/notify-events.cgi index 9c755af..4f2c331 100755 --- a/website/agenda/planung/notify-events.cgi +++ b/website/agenda/planung/notify-events.cgi @@ -3,10 +3,9 @@ use strict; use warnings; no warnings 'redefine'; +use utf8; -use URI::Escape(); use Data::Dumper; -use MIME::Lite(); use params(); use config(); @@ -21,6 +20,7 @@ use markup(); use studios(); use series(); use localization(); +use mail(); binmode STDOUT, ":utf8"; @@ -164,20 +164,7 @@ sub sendMail { $mail->{Cc} = $params->{cc} if defined $params->{cc}; $mail->{Subject} = $params->{subject} if defined $params->{subject}; $mail->{Data} = $params->{content} if defined $params->{content}; - - my $msg = MIME::Lite->new( - 'From' => $mail->{'From'}, - 'To' => $mail->{'To'}, - 'Cc' => $mail->{'Cc'}, - 'Reply-To' => $mail->{'Reply-To'}, - 'Subject' => $mail->{'Subject'}, - 'Data' => $mail->{'Data'}, - ); - - print '
';
-    $msg->print( \*STDOUT );
-    print '
'; - $msg->send; + mail::send($mail); } sub getMail { @@ -215,10 +202,10 @@ sub getMail { }; $mail->{Data} .= "nur zur Erinnerung...\n\n"; - $mail->{Data} .= "am $event->{weekday_name} ist die naechste '$event->{series_name}'-Sendung.\n\n"; + $mail->{Data} .= "am $event->{weekday_name} ist die nächste '$event->{series_name}'-Sendung.\n\n"; $mail->{Data} .= "$event->{source_base_url}$event->{widget_render_url}/$config->{controllers}->{event}/$event->{event_id}.html\n\n"; - $mail->{Data} .= "Gruss, $request->{user}\n"; + $mail->{Data} .= "Gruß, $request->{user}\n"; return $mail; }