Skip to content

Commit

Permalink
Add setting to override the list name in the Subject tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcourreges authored and Christopher Zimmermann committed Nov 24, 2013
1 parent 61b2dcb commit 263e7c2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
11 changes: 9 additions & 2 deletions minimalist.conf
Expand Up @@ -224,13 +224,20 @@
#
# Available values:
# no : don't touch subject
# yes : add "[list_name] " before original subject
# more : remove leading "Re: " if it's there and then add "[list_name] "
# yes : add "[tag] " before original subject
# more : remove leading "Re: " if it's there and then add "[tag] "
# By default "tag" is the list name. To override it, use "subject tag".
#
# Default to yes
#
#modify subject = no

# Tag used when modifying the subject.
#
# Defaults to empty which means use the list name.
#
#subject tag = My local ISP support

# Maximal count of subscribers per list, zero means no limits.
# Default to zero
#
Expand Down
13 changes: 8 additions & 5 deletions minimalist.pl
Expand Up @@ -329,6 +329,7 @@
print "\nCopy to sender: $lconf{copy_sender}\n".
"Reply-To list: $lconf{reply_to_list}\n".
"List GECOS: ".($lconf{list_gecos} ? $lconf{list_gecos} : "empty")."\n".
"Subject tag: ".($lconf{subject_tag} ? $lconf{subject_tag} : "empty")."\n".
"Substitute From: ".($lconf{outgoing_from} ? $lconf{outgoing_from} : "none")."\n".
"Admin: $lconf{admin}\n".
"Errors from MTA: ".($lconf{errors_to} eq 'drop' ? "drop" :
Expand Down Expand Up @@ -558,15 +559,16 @@
exit 0 if ($header =~ s/(^|\n)list-id:\s+(.*)\n/$1/i && $2 =~ /$list.$conf{domain}/i);

if ($conf{modify_subject} ne 'no') {
my $tag = $conf{subject_tag} // $list;
$orig_subj = $subject;
if ($conf{modify_subject} eq 'more') { # Remove leading "Re: "
$subject =~ s/^.*:\s+(\[$list\])/$1/ig }
$subject =~ s/^.*:\s+(\[\Q$tag\E\])/$1/ig }
else { # change anything before [...] to Re:
$subject =~ s/^(.*:\s+)+(\[$list\])/Re: $2/ig; }
$subject =~ s/^(.*:\s+)+(\[\Q$tag\E\])/Re: $2/ig; }

# Modify subject if it don't modified before
if ($subject !~ /^(.*:\s+)?\[$list\] /i) {
$subject = "[$list] ".$subject; }
# Modify subject if not already done
if ($subject !~ /^(.*:\s+)?\[\Q$tag\E\] /i) {
$subject = "[$tag] ".$subject; }
}

open LIST, "$conf{listdir}/$list/list" and do {
Expand Down Expand Up @@ -1724,6 +1726,7 @@ ($$)
}
}
when ('list gecos') { $nconf{list_gecos} = $value; }
when ('subject tag') { $nconf{subject_tag} = $value; }
when ('to recipient') { $nconf{to_recipient} = lc($value); }
}
# Both: local and global
Expand Down

0 comments on commit 263e7c2

Please sign in to comment.