Triple Entendre (triple_entendre) wrote,
Triple Entendre
triple_entendre

  • Mood:
  • Music:

procmail recipe for enhanced lj-notify

MYADDRESS="junk@example.com"
MYOTHERADDRESS="other@example.net"

:0
# Anything with lj's notifier service address anywhere in the headers
* lj_notify@livejournal.com
# Mail loops are evil. Don't be evil.
* !^X-Loop: $MYADDRESS
{
        #
        # Comments made in my journal or as replies to my comments
        #
        :0
        # first we'll grab the username if it's in the From: header
        # in the format "(brad - LJ Comment)"
        LJUSER=| formail -x"From: " \
                | sed "s/.*[(]\([a-z0-9_]*\) - LJ Comment)/\1/" \
                | tee --append ~/tmp/ljusers.log

        #if you wanted to test the above line, you might add something like
        #| tee --append ~/tmp/ljusers.log

        #
        # Comments I make in any journal, including mine
        #
        # I wish the notifier email would say who I'm replying to; that's how
        # I'd prefer to store it. Instead, we grab the owner of the journal
        # we posted in and use that.
        :0 B
        * You left a comment
        LJUSER=| formail -x"X-Lj-Journal: " \
        | tee --append ~/tmp/ljjournals.log

        #if you wanted to test the above line, you might add something like
        #| tee --append ~/tmp/ljjournals.log


        # change the headers so the message appears to be coming from the writer
        # we'll also throw their name in a new header X-LJ-User
        #
        # we'll use @livejournal.com, even though might not exist for user
        :0 fw
        | formail -i "From: $LJUSER@livejournal.com" \
                -I "X-Loop: $MYADDRESS" \
                -i "X-LJ-User: $LJUSER"

        # forward a copy to another account just in case
        #:0 c
        #! $MYOTHERADDRESS
}


EDIT: Here's an improved version.

MYADDRESS="junk@example.com"
MYOTHERADDRESS="other@example.net"

:0
# Anything with lj's notifier service address anywhere in the headers
* lj_notify@livejournal.com
# Mail loops are evil
* !^X-Loop: $MYADDRESS
{
        #
        # Comments I make in any journal, including mine
        #
        # I wish the notifier email would say who I'm replying to; that's how
        # I'd prefer to store it. Instead, we grab the owner of the journal
        # we posted in and use that.
        #
        :0 B
        * ^You left a comment
        LJUSER=| formail -x"X-Lj-Journal: " \
        | tee --append ~/tmp/ljjournals.log

        #if you wanted to test the above line, you might add something like
        #| tee --append ~/tmp/ljjournals.log


        #
        # Comments made in my journal or as replies to my comments
        #
        :0
        # we'll grab the username if it's in the From: header
        # in the format "(brad - LJ Comment)"
        LJUSER=| formail -x"From: " \
                | sed "s/.*[(]\([a-z0-9_]*\) - LJ Comment)/\1/" \
                | tee --append ~/tmp/ljusers.log

        #if you wanted to test the above line, you might add something like
        #| tee --append ~/tmp/ljusers.log


        # change the headers so the message appears to be coming from the writer
        # we'll also throw their name in a new header X-LJ-User
        #
        # we'll use @livejournal.com, even though might not really exist for user
        :0 fw
        | formail -i "From: $LJUSER@livejournal.com" \
                -I "X-Loop: $MYADDRESS" \
                -i "X-LJ-User: $LJUSER"

        # forward a copy to another account just in case
        #:0 c
        #! $MYOTHERADDRESS
}
Subscribe
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 2 comments