From 66061a7ca7849ae147b12bf0aca72bbc70821099 Mon Sep 17 00:00:00 2001 From: dakkar Date: Mon, 2 Jan 2017 17:35:52 +0000 Subject: ReplyTo can set a post address != return path --- lib/Sietima/Role/ReplyTo.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Sietima/Role/ReplyTo.pm b/lib/Sietima/Role/ReplyTo.pm index 56a8ed9..583b1de 100644 --- a/lib/Sietima/Role/ReplyTo.pm +++ b/lib/Sietima/Role/ReplyTo.pm @@ -2,6 +2,7 @@ package Sietima::Role::ReplyTo; use Moo::Role; use Sietima::Policy; use Types::Standard qw(Bool); +use Sietima::Types qw(Address AddressFromStr); use List::AllUtils qw(part); use namespace::clean; @@ -11,6 +12,13 @@ has munge_reply_to => ( default => 0, ); +has post_address => ( + is => 'lazy', + isa => Address, + coerce => AddressFromStr, +); +sub _build_post_address($self) { $self->return_path } + around munge_mail => sub ($orig,$self,$mail) { my @messages = $self->$orig($mail); my @ret; @@ -28,7 +36,7 @@ around munge_mail => sub ($orig,$self,$mail) { } elsif (not ($leave and $leave->@*)) { # all these recipients want munging - $m->mail->header_str_set('Reply-To',$self->return_path->address); + $m->mail->header_str_set('Reply-To',$self->post_address->address); push @ret,$m; } else { @@ -40,7 +48,7 @@ around munge_mail => sub ($orig,$self,$mail) { }); my $munged_mail = Email::MIME->new($m->mail->as_string); - $munged_mail->header_str_set('Reply-To',$self->return_path->address); + $munged_mail->header_str_set('Reply-To',$self->post_address->address); my $munged_message = Sietima::Message->new({ mail => $munged_mail, @@ -54,4 +62,11 @@ around munge_mail => sub ($orig,$self,$mail) { return @ret; }; +around list_addresses => sub ($orig,$self) { + return +{ + $self->$orig->%*, + post => $self->post_address, + }; +}; + 1; -- cgit v1.2.3