From e7a6cfa9311f463d9e3e96b6b56c998246b0652f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 14 Mar 2020 14:56:02 +0100 Subject: Correctly encode non-ASCII e-mail content. Fixes spamfilter issues. New dependency: MIME::Entity --- cpanfile | 3 ++- lib/Travelynx/Helper/Sendmail.pm | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cpanfile b/cpanfile index 7a869c5..51c57cb 100644 --- a/cpanfile +++ b/cpanfile @@ -3,10 +3,11 @@ requires 'CAM::PDF'; requires 'Crypt::Eksblowfish'; requires 'DateTime'; requires 'DateTime::Format::Strptime'; -requires 'Email::Sender'; +requires 'Email::Sender::Simple'; requires 'Geo::Distance'; requires 'Geo::Distance::XS'; requires 'List::UtilsBy'; +requires 'MIME::Entity'; requires 'Mojolicious'; requires 'Mojolicious::Plugin::Authentication'; requires 'Mojo::Pg'; diff --git a/lib/Travelynx/Helper/Sendmail.pm b/lib/Travelynx/Helper/Sendmail.pm index 73b08cd..d7c66b6 100644 --- a/lib/Travelynx/Helper/Sendmail.pm +++ b/lib/Travelynx/Helper/Sendmail.pm @@ -7,7 +7,7 @@ use 5.020; use Encode qw(encode); use Email::Sender::Simple qw(try_to_sendmail); -use Email::Simple; +use MIME::Entity; sub new { my ( $class, %opt ) = @_; @@ -18,14 +18,14 @@ sub new { sub custom { my ( $self, $to, $subject, $body ) = @_; - my $reg_mail = Email::Simple->create( - header => [ - To => $to, - From => $self->{config}{from}, - Subject => $subject, - 'Content-Type' => 'text/plain; charset=UTF-8', - ], - body => encode( 'utf-8', $body ), + my $reg_mail = MIME::Entity->build( + To => $to, + From => $from, + Subject => encode( 'MIME-Header', $subject ), + Type => 'text/plain', + Charset => 'UTF-8', + Encoding => 'quoted-printable', + Data => encode( 'utf-8', $body ), ); if ( $self->{config}->{disabled} ) { -- cgit v1.2.3