Correctly encode non-ASCII e-mail content. Fixes spamfilter issues.

New dependency: MIME::Entity
This commit is contained in:
Daniel Friesel 2020-03-14 14:56:02 +01:00
parent 871a44f15e
commit e7a6cfa931
2 changed files with 11 additions and 10 deletions

View file

@ -3,10 +3,11 @@ requires 'CAM::PDF';
requires 'Crypt::Eksblowfish'; requires 'Crypt::Eksblowfish';
requires 'DateTime'; requires 'DateTime';
requires 'DateTime::Format::Strptime'; requires 'DateTime::Format::Strptime';
requires 'Email::Sender'; requires 'Email::Sender::Simple';
requires 'Geo::Distance'; requires 'Geo::Distance';
requires 'Geo::Distance::XS'; requires 'Geo::Distance::XS';
requires 'List::UtilsBy'; requires 'List::UtilsBy';
requires 'MIME::Entity';
requires 'Mojolicious'; requires 'Mojolicious';
requires 'Mojolicious::Plugin::Authentication'; requires 'Mojolicious::Plugin::Authentication';
requires 'Mojo::Pg'; requires 'Mojo::Pg';

View file

@ -7,7 +7,7 @@ use 5.020;
use Encode qw(encode); use Encode qw(encode);
use Email::Sender::Simple qw(try_to_sendmail); use Email::Sender::Simple qw(try_to_sendmail);
use Email::Simple; use MIME::Entity;
sub new { sub new {
my ( $class, %opt ) = @_; my ( $class, %opt ) = @_;
@ -18,14 +18,14 @@ sub new {
sub custom { sub custom {
my ( $self, $to, $subject, $body ) = @_; my ( $self, $to, $subject, $body ) = @_;
my $reg_mail = Email::Simple->create( my $reg_mail = MIME::Entity->build(
header => [ To => $to,
To => $to, From => $from,
From => $self->{config}{from}, Subject => encode( 'MIME-Header', $subject ),
Subject => $subject, Type => 'text/plain',
'Content-Type' => 'text/plain; charset=UTF-8', Charset => 'UTF-8',
], Encoding => 'quoted-printable',
body => encode( 'utf-8', $body ), Data => encode( 'utf-8', $body ),
); );
if ( $self->{config}->{disabled} ) { if ( $self->{config}->{disabled} ) {