aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2017-03-24 16:32:52 +0000
committerdakkar <dakkar@thenautilus.net>2017-03-24 16:32:52 +0000
commit561dcb678dd6e8520e927365f3737315c0fe0577 (patch)
tree6788bc69a924a3dd39d080b804776fb681d85457 /lib
parentfix list headers (diff)
downloadSietima-561dcb678dd6e8520e927365f3737315c0fe0577.tar.gz
Sietima-561dcb678dd6e8520e927365f3737315c0fe0577.tar.bz2
Sietima-561dcb678dd6e8520e927365f3737315c0fe0577.zip
allow List-Post: NO
Diffstat (limited to 'lib')
-rw-r--r--lib/Sietima/Role/Headers.pm27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/Sietima/Role/Headers.pm b/lib/Sietima/Role/Headers.pm
index fe3f8a5..5ab0d58 100644
--- a/lib/Sietima/Role/Headers.pm
+++ b/lib/Sietima/Role/Headers.pm
@@ -61,6 +61,15 @@ sub _normalise_address($self,$address) {
} @items;
}
+sub _set_header($self,$mail,$name,$value) {
+ my $header_name = 'List-' . ucfirst($name =~ s{[^[:alnum:]]+}{-}gr);
+ my @items = $self->_normalise_address($value);
+
+ $mail->header_raw_set(
+ $header_name => join ', ', map { $_->as_header_raw } @items,
+ );
+}
+
sub _add_headers_to($self,$message) {
my $addresses = $self->list_addresses;
my $mail = $message->mail;
@@ -77,15 +86,19 @@ sub _add_headers_to($self,$message) {
# if nobody declared a "post" address, let's guess it's the same
# as the address we send from
- $addresses->{post} //= $return_path;
+ if (not exists $addresses->{post}) {
+ $self->_set_header( $mail, post => $return_path );
+ }
+ # but if they explicitly set a false value, this list does not
+ # allow posting, so we need to set the special value 'NO'
+ elsif (not $addresses->{post}) {
+ delete $addresses->{post};
+ $mail->header_raw_set('List-Post','NO');
+ }
+ # otherwise we can treat 'post' as normal
for my $name (sort keys $addresses->%*) {
- my $header_name = 'List-' . ucfirst($name =~ s{[^[:alnum:]]+}{-}gr);
- my @items = $self->_normalise_address($addresses->{$name});
-
- $mail->header_raw_set(
- $header_name => join ', ', map { $_->as_header_raw } @items,
- );
+ $self->_set_header( $mail, $name => $addresses->{$name} );
}
return;
}