diff --git a/dist.ini b/dist.ini index eb00f9a..bd959d0 100644 --- a/dist.ini +++ b/dist.ini @@ -9,6 +9,7 @@ copyright_holder = Ricardo Signes Moo = 2.000000 ; do not apply fatal warnings to us! MooX::Types::MooseLike = 0.15 ; InstanceOf uses ->isa Throwable::Error = 0.200003 ; with $obj->throw and ->throw($str) and Moo +Net::IDN::Encode = 0 Net::SMTP = 3.07 ; SSL support, fixed datasend diff --git a/lib/Email/Sender/Transport/SMTP.pm b/lib/Email/Sender/Transport/SMTP.pm index 35a162b..28e3269 100644 --- a/lib/Email/Sender/Transport/SMTP.pm +++ b/lib/Email/Sender/Transport/SMTP.pm @@ -8,6 +8,7 @@ use Email::Sender::Success::Partial; use Email::Sender::Role::HasMessage (); use Email::Sender::Util; use MooX::Types::MooseLike::Base qw(Bool Int Str HashRef); +use Net::IDN::Encode qw(domain_to_ascii); use Net::SMTP 3.07; # SSL support, fixed datasend use utf8 (); # See below. -- rjbs, 2015-05-14 @@ -105,7 +106,12 @@ has allow_partial_success => (is => 'ro', isa => Bool, default => sub { 0 }); =cut -has helo => (is => 'ro', isa => Str); +has helo => ( + is => 'ro', + isa => Str, + coerce => sub { domain_to_ascii( $_[0] ) } +); + has localaddr => (is => 'ro'); has localport => (is => 'ro', isa => Int); diff --git a/t/smtp-via-mock.t b/t/smtp-via-mock.t index c546cf6..16dacde 100644 --- a/t/smtp-via-mock.t +++ b/t/smtp-via-mock.t @@ -1,6 +1,7 @@ #!perl use strict; use warnings; +use utf8; use Test::More; BEGIN { @@ -32,7 +33,7 @@ BEGIN { $mock_smtp->{failaddr}{'permfail@example.net'} = [ 519 => 'Permanent STHU' ]; } -plan tests => 95; +plan tests => 97; use Email::Sender::Transport::SMTP; use Email::Sender::Transport::SMTP::Persistent; @@ -348,6 +349,16 @@ for my $class (qw( }, ); } + + { + local $test = 'helo idn conversion'; + local $sender = $class->new({ + helo => 'Bücher.ch', + }); + + is($sender->helo, 'xn--bcher-kva.ch', 'IDN conversion successful'); + } + } subtest "quoteaddr" => sub {