diff options
32 files changed, 251 insertions, 52 deletions
@@ -1,3 +1,6 @@ +1.1.2 2023-03-31 16:51:00+01:00 Europe/London + - new role NoSpoof::DMARC, which replaces the From only when needed + 1.1.1 2023-02-28 13:02:33+00:00 Europe/London - documentation fixes - simplified SubscriberOnly::Moderate @@ -20,6 +20,7 @@ lib/Sietima/Role/Headers.pm lib/Sietima/Role/ManualSubscription.pm lib/Sietima/Role/NoMail.pm lib/Sietima/Role/NoSpoof.pm +lib/Sietima/Role/NoSpoof/DMARC.pm lib/Sietima/Role/ReplyTo.pm lib/Sietima/Role/SubjectTag.pm lib/Sietima/Role/SubscriberOnly.pm @@ -50,6 +51,7 @@ t/tests/sietima/role/headers.t t/tests/sietima/role/manualsubscription.t t/tests/sietima/role/nomail.t t/tests/sietima/role/nospoof.t +t/tests/sietima/role/nospoof/dmarc.t t/tests/sietima/role/replyto.t t/tests/sietima/role/subject-tag.t t/tests/sietima/role/subscriberonly/drop.t @@ -44,6 +44,7 @@ "Email::Sender::Simple" : "2.600", "Email::Stuffer" : "0.020", "List::AllUtils" : "0.19", + "Mail::DMARC::PurePerl" : "1.20230215", "Moo" : "2.005005", "Moo::Role" : "2.005005", "MooX::Traits" : "0.005", @@ -65,6 +66,7 @@ "Data::Printer" : "1.001000", "Email::Sender::Transport::Test" : "2.600", "Import::Into" : "1.002005", + "Net::DNS::Resolver::Mock" : "1.20230216", "Path::Tiny" : "0.144", "Test2::API" : "1.302192", "Test2::V0" : "0.000145", @@ -82,7 +84,7 @@ "web" : "https://www.thenautilus.net/cgit/Sietima" } }, - "version" : "1.1.1", + "version" : "1.1.2", "x_generated_by_perl" : "v5.36.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.35", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" @@ -6,6 +6,7 @@ build_requires: Data::Printer: '1.001000' Email::Sender::Transport::Test: '2.600' Import::Into: '1.002005' + Net::DNS::Resolver::Mock: '1.20230216' Path::Tiny: '0.144' Test2::API: '1.302192' Test2::V0: '0.000145' @@ -32,6 +33,7 @@ requires: Email::Sender::Simple: '2.600' Email::Stuffer: '0.020' List::AllUtils: '0.19' + Mail::DMARC::PurePerl: '1.20230215' Moo: '2.005005' Moo::Role: '2.005005' MooX::Traits: '0.005' @@ -49,7 +51,7 @@ requires: resources: homepage: https://www.thenautilus.net/SW/Sietima/ repository: https://www.thenautilus.net/cgit/Sietima -version: 1.1.1 +version: 1.1.2 x_generated_by_perl: v5.36.0 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' diff --git a/Makefile.PL b/Makefile.PL index bb74d5f..38c144a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -25,6 +25,7 @@ my %WriteMakefileArgs = ( "Email::Sender::Simple" => "2.600", "Email::Stuffer" => "0.020", "List::AllUtils" => "0.19", + "Mail::DMARC::PurePerl" => "1.20230215", "Moo" => "2.005005", "Moo::Role" => "2.005005", "MooX::Traits" => "0.005", @@ -43,15 +44,16 @@ my %WriteMakefileArgs = ( "Data::Printer" => "1.001000", "Email::Sender::Transport::Test" => "2.600", "Import::Into" => "1.002005", + "Net::DNS::Resolver::Mock" => "1.20230216", "Path::Tiny" => "0.144", "Test2::API" => "1.302192", "Test2::V0" => "0.000145", "URI" => "5.17", "lib" => "0.65" }, - "VERSION" => "1.1.1", + "VERSION" => "1.1.2", "test" => { - "TESTS" => "t/*.t t/tests/*.t t/tests/sietima/*.t t/tests/sietima/multi-role/*.t t/tests/sietima/role/*.t t/tests/sietima/role/subscriberonly/*.t" + "TESTS" => "t/*.t t/tests/*.t t/tests/sietima/*.t t/tests/sietima/multi-role/*.t t/tests/sietima/role/*.t t/tests/sietima/role/nospoof/*.t t/tests/sietima/role/subscriberonly/*.t" } ); @@ -68,9 +70,11 @@ my %FallbackPrereqs = ( "Email::Stuffer" => "0.020", "Import::Into" => "1.002005", "List::AllUtils" => "0.19", + "Mail::DMARC::PurePerl" => "1.20230215", "Moo" => "2.005005", "Moo::Role" => "2.005005", "MooX::Traits" => "0.005", + "Net::DNS::Resolver::Mock" => "1.20230216", "Path::Tiny" => "0.144", "Test2::API" => "1.302192", "Test2::V0" => "0.000145", diff --git a/lib/Sietima.pm b/lib/Sietima.pm index d30be2b..2bace38 100644 --- a/lib/Sietima.pm +++ b/lib/Sietima.pm @@ -14,7 +14,7 @@ use Email::Address; use namespace::clean; with 'MooX::Traits'; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: minimal mailing list manager @@ -145,7 +145,7 @@ Sietima - minimal mailing list manager =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/CmdLine.pm b/lib/Sietima/CmdLine.pm index ca88c71..57fbf18 100644 --- a/lib/Sietima/CmdLine.pm +++ b/lib/Sietima/CmdLine.pm @@ -8,7 +8,7 @@ use App::Spec; use Sietima::Runner; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: run Sietima as a command-line application @@ -83,7 +83,7 @@ Sietima::CmdLine - run Sietima as a command-line application =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/HeaderURI.pm b/lib/Sietima/HeaderURI.pm index 2b04eb5..b56f8f0 100644 --- a/lib/Sietima/HeaderURI.pm +++ b/lib/Sietima/HeaderURI.pm @@ -8,7 +8,7 @@ use Types::URI qw(Uri is_Uri); use Email::Address; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: annotated URI for list headers @@ -97,7 +97,7 @@ Sietima::HeaderURI - annotated URI for list headers =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/MailStore.pm b/lib/Sietima/MailStore.pm index 911c183..fe9d4ca 100644 --- a/lib/Sietima/MailStore.pm +++ b/lib/Sietima/MailStore.pm @@ -3,7 +3,7 @@ use Moo::Role; use Sietima::Policy; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: interface for mail stores @@ -25,7 +25,7 @@ Sietima::MailStore - interface for mail stores =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 DESCRIPTION diff --git a/lib/Sietima/MailStore/FS.pm b/lib/Sietima/MailStore/FS.pm index 5fc1814..4f43d26 100644 --- a/lib/Sietima/MailStore/FS.pm +++ b/lib/Sietima/MailStore/FS.pm @@ -8,7 +8,7 @@ use Sietima::Types qw(EmailMIME TagName); use Digest::SHA qw(sha1_hex); use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: filesystem-backed email store @@ -150,7 +150,7 @@ Sietima::MailStore::FS - filesystem-backed email store =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Message.pm b/lib/Sietima/Message.pm index 7073115..45b2e2e 100644 --- a/lib/Sietima/Message.pm +++ b/lib/Sietima/Message.pm @@ -10,7 +10,7 @@ use Sietima::Subscriber; use Email::MIME; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: an email message with an envelope @@ -64,7 +64,7 @@ Sietima::Message - an email message with an envelope =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Policy.pm b/lib/Sietima/Policy.pm index 68e85a5..c3f8533 100644 --- a/lib/Sietima/Policy.pm +++ b/lib/Sietima/Policy.pm @@ -4,7 +4,7 @@ use strict; use warnings; use feature ':5.36'; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: pragma for Sietima modules @@ -31,7 +31,7 @@ Sietima::Policy - pragma for Sietima modules =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/AvoidDups.pm b/lib/Sietima/Role/AvoidDups.pm index 7f7a5c6..565d773 100644 --- a/lib/Sietima/Role/AvoidDups.pm +++ b/lib/Sietima/Role/AvoidDups.pm @@ -4,7 +4,7 @@ use Sietima::Policy; use Email::Address; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: prevent people from receiving the same message multiple times @@ -39,7 +39,7 @@ Sietima::Role::AvoidDups - prevent people from receiving the same message multip =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/Debounce.pm b/lib/Sietima/Role/Debounce.pm index 9e143b4..be0b7b6 100644 --- a/lib/Sietima/Role/Debounce.pm +++ b/lib/Sietima/Role/Debounce.pm @@ -3,7 +3,7 @@ use Moo::Role; use Sietima::Policy; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: avoid mail loops @@ -36,7 +36,7 @@ Sietima::Role::Debounce - avoid mail loops =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/Headers.pm b/lib/Sietima/Role/Headers.pm index e4422c6..1c536d8 100644 --- a/lib/Sietima/Role/Headers.pm +++ b/lib/Sietima/Role/Headers.pm @@ -6,7 +6,7 @@ use Types::Standard qw(Str); use Sietima::Types qw(HeaderUriFromThings); use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: adds standard list-related headers to messages @@ -87,7 +87,7 @@ Sietima::Role::Headers - adds standard list-related headers to messages =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/ManualSubscription.pm b/lib/Sietima/Role/ManualSubscription.pm index 5c884ec..cfd290f 100644 --- a/lib/Sietima/Role/ManualSubscription.pm +++ b/lib/Sietima/Role/ManualSubscription.pm @@ -4,7 +4,7 @@ use Sietima::Policy; use Sietima::HeaderURI; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: adds standard list-related headers to messages with 'Sietima::Role::WithOwner'; @@ -41,7 +41,7 @@ Sietima::Role::ManualSubscription - adds standard list-related headers to messag =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/NoMail.pm b/lib/Sietima/Role/NoMail.pm index 0f333ea..febbfdc 100644 --- a/lib/Sietima/Role/NoMail.pm +++ b/lib/Sietima/Role/NoMail.pm @@ -3,7 +3,7 @@ use Moo::Role; use Sietima::Policy; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: don't send mail to those who don't want it @@ -28,7 +28,7 @@ Sietima::Role::NoMail - don't send mail to those who don't want it =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/NoSpoof.pm b/lib/Sietima/Role/NoSpoof.pm index 88efdc7..aa81a2c 100644 --- a/lib/Sietima/Role/NoSpoof.pm +++ b/lib/Sietima/Role/NoSpoof.pm @@ -4,7 +4,7 @@ use Sietima::Policy; use Email::Address; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: never sends out messages from subscribers' addresses @@ -37,7 +37,7 @@ Sietima::Role::NoSpoof - never sends out messages from subscribers' addresses =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/NoSpoof/DMARC.pm b/lib/Sietima/Role/NoSpoof/DMARC.pm new file mode 100644 index 0000000..13624d3 --- /dev/null +++ b/lib/Sietima/Role/NoSpoof/DMARC.pm @@ -0,0 +1,119 @@ +package Sietima::Role::NoSpoof::DMARC; +use Moo::Role; +use Sietima::Policy; +use Email::Address; +use Mail::DMARC::PurePerl; +use namespace::clean; + +our $VERSION = '1.1.2'; # VERSION +# ABSTRACT: send out messages from subscribers' addresses only if DMARC allows it + + +with 'Sietima::Role::WithPostAddress'; + +# mostly for testing +has dmarc_resolver => ( is => 'ro' ); + +around munge_mail => sub ($orig,$self,$incoming_mail) { + my $sender = $self->post_address->address; + my ($from) = Email::Address->parse($incoming_mail->header_str('From')); + my $from_domain = $from->host; + + my $dmarc = Mail::DMARC::PurePerl->new( + resolver => $self->dmarc_resolver, + ); + $dmarc->header_from($from_domain); + + if (my $policy = $dmarc->discover_policy) { + # sp applies to sub-domains, defaults to p; p applies to the + # domain itself, and is required + my $relevant_value = $dmarc->is_subdomain + ? ( $policy->sp // $policy->p ) + : $policy->p; + + if ($relevant_value ne 'none') { + $incoming_mail->header_str_set( + 'Original-From' => $from, + ); + + $from->address($sender); + + $incoming_mail->header_str_set( + From => $from, + ); + + return $self->$orig($incoming_mail); + } + } + + $incoming_mail->header_str_set( + Sender => $sender, + ); + + return $self->$orig($incoming_mail); + +}; + +1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::NoSpoof::DMARC - send out messages from subscribers' addresses only if DMARC allows it + +=head1 VERSION + +version 1.1.2 + +=head1 SYNOPSIS + + my $sietima = Sietima->with_traits('NoSpoof::DMARC')->new(\%args); + +=head1 DESCRIPTION + +A L<< C<Sietima> >> list with this role applied will replace the +C<From> address with its own L<< +C<post_address>|Sietima::Role::WithPostAddress >> (this is a +"sub-role" of L<< C<WithPostAddress>|Sietima::Role::WithPostAddress +>>) I<if> the originating address's DMARC policy requires it. + +This will make the list DMARC-compliant while minimising the changes +to the messages. + +The original C<From> address will be preserved in the C<Original-From> +header, as required by RFC 5703. + +=head2 Some more details + +DMARC requires L<"identifier +alignment"|https://datatracker.ietf.org/doc/html/rfc7489#section-3.1>, +essentially the C<MAIL FROM> (envelope) and the header C<From> must +have the same domain (or at least belong to the same "organisational +domain", i.e. be both under a common non-top-level domain, roughly). + +Therefore, a mailing list that forwards a message sent from a +DMARC-enabled domain, I<must> rewrite the C<From> header, otherwise +the message will be discarded by recipient servers. If the originating +domain does not publish a DMARC policy (or publishes a C<none> +policy), the mailing list can leave the C<From> as is, but should add +a C<Sender> header with the list's own address. + +This role does exactly that. + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2023 by Gianni Ceccarelli <dakkar@thenautilus.net>. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Sietima/Role/ReplyTo.pm b/lib/Sietima/Role/ReplyTo.pm index 416e387..106c622 100644 --- a/lib/Sietima/Role/ReplyTo.pm +++ b/lib/Sietima/Role/ReplyTo.pm @@ -5,7 +5,7 @@ use Types::Standard qw(Bool); use List::AllUtils qw(part); use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: munge the C<Reply-To> header @@ -76,7 +76,7 @@ Sietima::Role::ReplyTo - munge the C<Reply-To> header =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/SubjectTag.pm b/lib/Sietima/Role/SubjectTag.pm index d215f5e..b6b9159 100644 --- a/lib/Sietima/Role/SubjectTag.pm +++ b/lib/Sietima/Role/SubjectTag.pm @@ -4,7 +4,7 @@ use Sietima::Policy; use Types::Standard qw(Str); use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: add a tag to messages' subjects @@ -40,7 +40,7 @@ Sietima::Role::SubjectTag - add a tag to messages' subjects =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/SubscriberOnly.pm b/lib/Sietima/Role/SubscriberOnly.pm index 2ecb160..5df9636 100644 --- a/lib/Sietima/Role/SubscriberOnly.pm +++ b/lib/Sietima/Role/SubscriberOnly.pm @@ -7,7 +7,7 @@ use Types::Standard qw(Object CodeRef); use Type::Params -sigs; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: base role for "closed" lists @@ -51,7 +51,7 @@ Sietima::Role::SubscriberOnly - base role for "closed" lists =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/SubscriberOnly/Drop.pm b/lib/Sietima/Role/SubscriberOnly/Drop.pm index 0eb63b0..1914f78 100644 --- a/lib/Sietima/Role/SubscriberOnly/Drop.pm +++ b/lib/Sietima/Role/SubscriberOnly/Drop.pm @@ -3,7 +3,7 @@ use Moo::Role; use Sietima::Policy; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: drop messages from non-subscribers @@ -26,7 +26,7 @@ Sietima::Role::SubscriberOnly::Drop - drop messages from non-subscribers =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/SubscriberOnly/Moderate.pm b/lib/Sietima/Role/SubscriberOnly/Moderate.pm index 1450597..9de2967 100644 --- a/lib/Sietima/Role/SubscriberOnly/Moderate.pm +++ b/lib/Sietima/Role/SubscriberOnly/Moderate.pm @@ -4,7 +4,7 @@ use Sietima::Policy; use Email::Stuffer; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: moderate messages from non-subscribers @@ -139,7 +139,7 @@ Sietima::Role::SubscriberOnly::Moderate - moderate messages from non-subscribers =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/WithMailStore.pm b/lib/Sietima/Role/WithMailStore.pm index 7fc1e37..f30fde4 100644 --- a/lib/Sietima/Role/WithMailStore.pm +++ b/lib/Sietima/Role/WithMailStore.pm @@ -4,7 +4,7 @@ use Sietima::Policy; use Sietima::Types qw(MailStore MailStoreFromHashRef); use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: role for lists with a store for messages @@ -29,7 +29,7 @@ Sietima::Role::WithMailStore - role for lists with a store for messages =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/WithOwner.pm b/lib/Sietima/Role/WithOwner.pm index 6800ab0..c7c4d5c 100644 --- a/lib/Sietima/Role/WithOwner.pm +++ b/lib/Sietima/Role/WithOwner.pm @@ -4,7 +4,7 @@ use Sietima::Policy; use Sietima::Types qw(Address AddressFromStr); use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: role for lists with an owner @@ -37,7 +37,7 @@ Sietima::Role::WithOwner - role for lists with an owner =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Role/WithPostAddress.pm b/lib/Sietima/Role/WithPostAddress.pm index f8ad443..433b2ec 100644 --- a/lib/Sietima/Role/WithPostAddress.pm +++ b/lib/Sietima/Role/WithPostAddress.pm @@ -4,7 +4,7 @@ use Sietima::Policy; use Sietima::Types qw(Address AddressFromStr); use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: role for lists with a posting address @@ -36,7 +36,7 @@ Sietima::Role::WithPostAddress - role for lists with a posting address =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 SYNOPSIS diff --git a/lib/Sietima/Runner.pm b/lib/Sietima/Runner.pm index b4100d8..816f12a 100644 --- a/lib/Sietima/Runner.pm +++ b/lib/Sietima/Runner.pm @@ -3,7 +3,7 @@ use Moo; use Sietima::Policy; use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: C<App::Spec::Run> for Sietima @@ -32,7 +32,7 @@ Sietima::Runner - C<App::Spec::Run> for Sietima =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 DESCRIPTION diff --git a/lib/Sietima/Subscriber.pm b/lib/Sietima/Subscriber.pm index a1c047a..e25f8c6 100644 --- a/lib/Sietima/Subscriber.pm +++ b/lib/Sietima/Subscriber.pm @@ -8,7 +8,7 @@ use Email::Address; use List::AllUtils qw(any); use namespace::clean; -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: a subscriber to a mailing list @@ -65,7 +65,7 @@ Sietima::Subscriber - a subscriber to a mailing list =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 DESCRIPTION diff --git a/lib/Sietima/Types.pm b/lib/Sietima/Types.pm index 2d9c6b4..8652501 100644 --- a/lib/Sietima/Types.pm +++ b/lib/Sietima/Types.pm @@ -13,7 +13,7 @@ use Type::Library Subscriber SubscriberFromAddress SubscriberFromStr SubscriberFromHashRef Transport MailStore MailStoreFromHashRef); -our $VERSION = '1.1.1'; # VERSION +our $VERSION = '1.1.2'; # VERSION # ABSTRACT: type library for Sietima @@ -85,7 +85,7 @@ Sietima::Types - type library for Sietima =head1 VERSION -version 1.1.1 +version 1.1.2 =head1 DESCRIPTION diff --git a/t/author-no-tabs.t b/t/author-no-tabs.t index 8005d5e..7898f4b 100644 --- a/t/author-no-tabs.t +++ b/t/author-no-tabs.t @@ -28,6 +28,7 @@ my @files = ( 'lib/Sietima/Role/ManualSubscription.pm', 'lib/Sietima/Role/NoMail.pm', 'lib/Sietima/Role/NoSpoof.pm', + 'lib/Sietima/Role/NoSpoof/DMARC.pm', 'lib/Sietima/Role/ReplyTo.pm', 'lib/Sietima/Role/SubjectTag.pm', 'lib/Sietima/Role/SubscriberOnly.pm', @@ -53,6 +54,7 @@ my @files = ( 't/tests/sietima/role/manualsubscription.t', 't/tests/sietima/role/nomail.t', 't/tests/sietima/role/nospoof.t', + 't/tests/sietima/role/nospoof/dmarc.t', 't/tests/sietima/role/replyto.t', 't/tests/sietima/role/subject-tag.t', 't/tests/sietima/role/subscriberonly/drop.t', diff --git a/t/tests/sietima/role/nospoof/dmarc.t b/t/tests/sietima/role/nospoof/dmarc.t new file mode 100644 index 0000000..18d70c8 --- /dev/null +++ b/t/tests/sietima/role/nospoof/dmarc.t @@ -0,0 +1,65 @@ +#!perl +use lib 't/lib'; +use Test::Sietima; +use Net::DNS::Resolver::Mock; + +my $resolver = Net::DNS::Resolver::Mock->new(); + +my $s = make_sietima( + with_traits => ['NoSpoof::DMARC'], + subscribers => [ + 'one@users.example.com', + ], + dmarc_resolver => $resolver, +); + +sub test_rewriting($from) { + subtest "$from should rewrite" => sub { + test_sending( + sietima => $s, + mail => { + from => "a user <$from>", + }, + mails => [ + object { + call [ header_str => 'from' ] => '"a user" <'.$s->return_path->address.'>'; + call [ header_str => 'original-from' ] => qq{"a user" <$from>}; + }, + ], + ); + } +} + +sub test_no_rewriting($from) { + subtest "$from should not rewrite" => sub { + test_sending( + sietima => $s, + mail => { + from => "a user <$from>", + }, + mails => [ + object { + call [ header_str => 'sender' ] => $s->return_path->address; + call [ header_str => 'from' ] => qq{"a user" <$from>}; + }, + ], + ); + } +} + +$resolver->zonefile_parse(<<'EOZ'); +_dmarc.none-none-pol.com 3600 TXT "v=DMARC1; p=none; sp=none; rua=mailto:foo@example.com" +_dmarc.none-q-pol.com 3600 TXT "v=DMARC1; p=none; sp=quarantine; rua=mailto:foo@example.com" +_dmarc.q-q-pol.com 3600 TXT "v=DMARC1; p=quarantine; sp=quarantine; rua=mailto:foo@example.com" +EOZ + +test_no_rewriting 'foo@none-none-pol.com'; +test_no_rewriting 'foo@sub.none-none-pol.com'; + +test_no_rewriting 'foo@none-q-pol.com'; +test_rewriting 'foo@sub.none-q-pol.com'; + +test_rewriting 'foo@q-q-pol.com'; +test_rewriting 'foo@sub.q-q-pol.com'; + +done_testing; |