# ---------------------------------------------------------------------------
# PEP Based Mailing List
#
# By Mark Morley
# September, 2006
# ---------------------------------------------------------------------------
# --[ DISPATCH HANDLER ]-----------------------------------------------------
jump if x-envelope-to,envelope-to is {ListName}@{DomainName} to post
jump if x-envelope-to,envelope-to matches {ListName}-subscribe*@{DomainName} to subscribe
jump if x-envelope-to,envelope-to is {ListName}-unsubscribe@{DomainName} to unsubscribe
jump if true to end
# --[ POST HANDLER ]---------------------------------------------------------
@post
# If there is already a List-Post header, then it's the copy that came from
# the distribution (ie: not the original). Do we want to keep a copy or
# delete it?
jump if list-post is not to skip
keep if KeepCopy is yes
exit
@skip
# The admin can always post
jump if returnaddress is {AdminAddress} to ok
# Anyone listed as a poster can always post
jump if returnaddress is in {ListName}.posters to ok
# If this is a oneway list, then nobody else can post
fail if ListType is oneway with "You are not allowed to post to this mailing list"
# Otherwise, members can post
jump if returnaddress is in {ListName}.members to ok
# If this is a closed list, non-members can't post
fail if ListType is closed with "You are not allowed to post to this mailing list"
@ok
# The sender is ok, so let's add some standard mailing list headers:
insert if true List-Owner
insert if true List-Post
insert if true List-Subscribe
insert if true List-Unsubscribe
# Add a tag to the subject if required
jump if subjecttag is none to skip
jump if subject contains {SubjectTag} to skip
strip if true subject
insert if true Subject "{SubjectTag} {subject}"
@skip
# Should replies go back to the list? Replace the Reply-To header
jump if ReplyToList is no to @skip
strip if true reply-to
insert if true Reply-To {ListName}@{DomainName}
@skip
# And add a new TO: header that contains only the list address, since we
# have to have a To: field or it won't work
insert if true To {ListName}@{DomainName}
# Enable multimatch
enable multimatch
# Send it to the members
distribute if true to {ListName}.members {ListName}-bounces@{DomainName}
# Archive it
jump if Archive does not match "www/*" to skip
mkdir if true "{Archive}"
save if true "{Archive}/{PEP_ID}.msg"
@skip
# All done!
exit
# --[ SUBSCRIBE HANDLER ]----------------------------------------------------
@subscribe
# Do we allow unattended subscriptions?
fail if Subscribe is no with "Unattended subscriptions are currently disabled"
# Is the sender already subscribed?
fail if returnaddress is in {ListName}.members with "You are already subscribed to this list"
# If this is not a confirmation, send a confirmation request
jump if x-envelope-to,envelope-to regex "{ListName}-subscribe/(.+)@{DomainName}" to skip
append if true to temp/{ListName}.{PEP_ID}.pep with {returnaddress}
reply if true with {ListName}.confirm
@skip
# This is a confirmation, but is it one we're waiting for?
fail if returnaddress is not in temp/{ListName}.{RX1}.pep with "Please try subscribing again."
# It's good, subscribe the sender
unlink if true temp/{ListName}.{RX1}.pep
append if true to {ListName}.members {returnaddress}
append if true to {ListName}.log "{TimeStamp} [{IP}] {returnaddress} subscribed"
reply if true with {ListName}.subscribed
# All done!
exit
# --[ UNSUBSCRIBE HANDLER ]--------------------------------------------------
@unsubscribe
# Is the sender subscribed?
fail if returnaddress is not in {ListName}.members with "{returnaddress} is not in my subscription list"
# Remove the sender
remove if true {ListName}.members {returnaddress}
append if true to {ListName}.log "{TimeStamp} [{IP}] {returnaddress} unsubscribed"
reply if true with {ListName}.unsubscribed
# All done!
exit
# --[ END ]------------------------------------------------------------------
@end
|