- my ($hdr) = @_;
- my %cc; # everyone else
- my $to; # this is the From address
-
- foreach my $h (qw(From To Cc)) {
- my $v = $hdr->header($h);
- defined($v) && ($v ne '') or next;
- my @addrs = PublicInbox::Address::emails($v);
- foreach my $address (@addrs) {
- my $dst = lc($address);
- $cc{$dst} ||= $address;
- $to ||= $dst;
+ my ($ibx, $hdr) = @_;
+ my $cc = {}; # everyone else
+ my $to; # this is the From address by default
+ my $reply_to_all = 'reply-to-all'; # the only good default :P
+ my $reply_to_cfg = $ibx->{replyto};
+
+ $reply_to_cfg ||= ':all';
+ if ($reply_to_cfg =~ /\A:none=(.*)/) {
+ my $msg = $1;
+ $msg = 'replies disabled' if $msg eq '';
+ return \$msg;
+ }
+
+ foreach my $rt (split(/\s*,\s*/, $reply_to_cfg)) {
+ if ($rt eq ':all') {
+ foreach my $h (@reply_headers) {
+ my $v = $hdr->header($h);
+ defined($v) && ($v ne '') or next;
+ my @addrs = PublicInbox::Address::emails($v);
+ add_addrs(\$to, $cc, @addrs);
+ }
+ } elsif ($rt eq ':list') {
+ $reply_to_all = 'reply-to-list';
+ add_addrs(\$to, $cc, $ibx->{-primary_address});
+ } elsif ($rt =~ /\A(?:$reply_headers)\z/io) {
+ # ugh, this is weird...
+ my $v = $hdr->header($rt);
+ if (defined($v) && ($v ne '')) {
+ my @addrs = PublicInbox::Address::emails($v);
+ add_addrs(\$to, $cc, @addrs);
+ }
+ } elsif ($rt =~ /@/) {
+ add_addrs(\$to, $cc, $rt);
+ } else {
+ warn "Unrecognized replyto = '$rt' in config\n";