mail.pm: convert to ascii
use Text::Unidecode to decode unicode, to prevent spam filter ignoring oddly encoded emails.
This commit is contained in:
@@ -96,6 +96,7 @@ apt-get install <deb-package>
|
|||||||
libmime-tools-perl
|
libmime-tools-perl
|
||||||
libsession-token-perl
|
libsession-token-perl
|
||||||
libtext-multimarkdown-perl
|
libtext-multimarkdown-perl
|
||||||
|
libtext-unidecode
|
||||||
libtext-wikicreole-perl
|
libtext-wikicreole-perl
|
||||||
liburi-escape-xs-perl
|
liburi-escape-xs-perl
|
||||||
perlmagick
|
perlmagick
|
||||||
|
|||||||
@@ -3,11 +3,27 @@ package mail;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
no warnings 'redefine';
|
no warnings 'redefine';
|
||||||
|
use utf8;
|
||||||
|
|
||||||
use Email::Sender::Simple();
|
use Email::Sender::Simple();
|
||||||
use Email::Simple();
|
use Email::Simple();
|
||||||
use MIME::Words qw(encode_mimeword);
|
use Text::Unidecode qw(unidecode);
|
||||||
use MIME::QuotedPrint qw(encode_qp);
|
|
||||||
|
sub to_ascii {
|
||||||
|
my ($s) = @_;
|
||||||
|
my %translate = qw(
|
||||||
|
Ä Ae
|
||||||
|
ä ae
|
||||||
|
Ö Oe
|
||||||
|
ö oe
|
||||||
|
Ü Ue
|
||||||
|
ü ue
|
||||||
|
ß ss
|
||||||
|
);
|
||||||
|
$s =~ s/([ÄäÖöÜüß])/$translate{$1}/g;
|
||||||
|
$s = unidecode $s;
|
||||||
|
return $s;
|
||||||
|
}
|
||||||
|
|
||||||
sub send($) {
|
sub send($) {
|
||||||
my ($mail) = @_;
|
my ($mail) = @_;
|
||||||
@@ -15,14 +31,13 @@ sub send($) {
|
|||||||
my $email = Email::Simple->create(
|
my $email = Email::Simple->create(
|
||||||
header => [
|
header => [
|
||||||
'Content-Type' => 'text/plain;',
|
'Content-Type' => 'text/plain;',
|
||||||
'Content-Transfer-Encoding' => 'quoted-printable',
|
|
||||||
'From' => $mail->{'From'},
|
'From' => $mail->{'From'},
|
||||||
'To' => $mail->{'To'},
|
'To' => $mail->{'To'},
|
||||||
'Cc' => $mail->{'Cc'},
|
'Cc' => $mail->{'Cc'},
|
||||||
'Reply-To' => $mail->{'Reply-To'},
|
'Reply-To' => $mail->{'Reply-To'},
|
||||||
'Subject' => encode_mimeword($mail->{'Subject'}, 'b', 'UTF-8')
|
'Subject' => to_ascii($mail->{'Subject'})
|
||||||
],
|
],
|
||||||
body => encode_qp($mail->{'Data'}),
|
body => to_ascii($mail->{'Data'})
|
||||||
);
|
);
|
||||||
Email::Sender::Simple->send($email);
|
Email::Sender::Simple->send($email);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user