tAdd rpinit, rpsee, rpdedup and rpenclosure. - rohrpost - A commandline mail client to change the world as we see it.
 (HTM) git clone git://r-36.net/rohrpost
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit df8ffff19c2a6b84019a9eb888b4400652d24746
 (DIR) parent ba2b7832201fc7c056db37c33e8dff01fcc4117e
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       Date:   Wed, 30 Mar 2016 17:08:04 +0200
       
       Add rpinit, rpsee, rpdedup and rpenclosure.
       
       rpsee is for mailcap
       
       Diffstat:
         bin/rpdedup                         |      43 ++++++++++++++++++++++++++++++
         bin/rpenclosure                     |      11 +++++++++++
         bin/rpinit                          |     160 +++++++++++++++++++++++++++++++
         bin/rpsee                           |      10 ++++++++++
       
       4 files changed, 224 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/bin/rpdedup b/bin/rpdedup
       t@@ -0,0 +1,43 @@
       +#!/bin/sh
       +
       +set -x
       +
       +if [ $# -lt 4 ];
       +then
       +        printf "usage: %s cfgfrom folderfrom\n" \
       +                "$(basename $0)" >&2
       +        exit 1
       +fi
       +
       +cfg="$1"
       +fold="$2"
       +
       +tmpfile="$(mktemp)"
       +rpview -ve message-id -c "$cfg" -m "$fold" : > "${tmpfile}"
       +
       +tmpfilesu="$(mktemp)"
       +cat "${tmpfile}" | sort | uniq -d  > "${tmpfilesu}"
       +
       +uuid=$(uuidgen)
       +uuidseq="${uuid}seq"
       +uuidtmp="${uuid}tmp"
       +
       +cat "${tmpfilesu}" \
       +        | while read -r line;
       +do
       +        rppick -qe "$uuidtmp" -c "$cfg" -m "$fold" :header message-id "${line}"
       +        if [ -z "$(rpmark -vc "$cfg" -m "$fold" "$uuidtmp" \
       +                        | cut -d' ' -f 3 )" ];
       +        then
       +                rpmark -c "$cfg" -m "$fold" -a "$uuidseq" "${uuidtmp}[0]"
       +        fi
       +done
       +
       +if [ -n "$(rpmark -vc "$cfg" -m "$fold" "$uuidseq")" ];
       +then
       +        rprm -c "$cfg" -m "$fold" "$uuidseq"
       +fi
       +
       +rpmark -d "$uuidseq"
       +rpmark -d "$uuidtmp"
       +
 (DIR) diff --git a/bin/rpenclosure b/bin/rpenclosure
       t@@ -0,0 +1,11 @@
       +#!/bin/sh
       +
       +if [ $# -lt 1 ];
       +then
       +        printf "usage. %s msgid\n" "$(basename $0)" 2>&1
       +        exit 1
       +fi
       +
       +msgid="$*"
       +printf "%s\n" "$(rpview $msgid | awk '/^Enclosure:/ {print $2}' | tr -d '\r')"
       +
 (DIR) diff --git a/bin/rpinit b/bin/rpinit
       t@@ -0,0 +1,160 @@
       +#!/bin/sh
       +
       +shareprefix="SHAREPREFIX"
       +
       +printf "Welcome to Rohrpost!
       +
       +Rohrpost is a commandline client for e-mail receiving and sending. It allows
       +this task to be completed in less time than every other e-mail client.
       +
       +Let's start initializing your rohrpost setup.\n"
       +
       +if [ $# -gt 0 ];
       +then
       +        profile="$1"
       +        printf "\nYou have selected via commandline to create the '%s' profile.\n" \
       +                "$profile"
       +else
       +        printf "What should be the name of the profile? > "
       +        read -r profile
       +        [ $? -gt 0 ] && exit 1
       +fi
       +
       +printf "Running rppath -ic \"$profile\".\n"
       +rppath -ic "$profile"
       +[ $? -gt 0 ] && exit 1
       +
       +printf "Now the configuration begins.
       +
       +Please enter the string value that should appear in the From: header
       +automatically when you create (_rpcomp_), answer (_rprepl_) or forward (_rpfwd_) 
       +an e-mail.\n"
       +
       +printf "defaultfrom = "
       +read -r defaultfrom
       +[ $? -gt 0 ] && exit 1 
       +rpcfg -c "$profile" defaultfrom "$defaultfrom"
       +
       +printf "Please enter the network specification of your IMAP server.
       +
       +Network specifications are for example:
       +        tcp!mail.example.com!imap
       +        tcp!mail.example.com!143
       +
       +For a direct TLS connection:
       +        tcps!mail.example.com!imaps
       +        tcps!mail.example.com!993
       +
       +Don't be worried, if your server supports STARTTLS, then rohrpost will
       +automatically use it.\n"
       +
       +printf "IMAP netspec = "
       +read -r imapnet
       +[ $? -gt 0 ] && exit 1
       +rpcfg -c "$profile" imapnet "$imapnet"
       +
       +printf "The login credentials.
       +
       +Here rohrpost only supports the PLAIN login method. So be sure to have
       +STARTTLS or a direct SSL/TLS connection to your IMAP server.\n"
       +
       +printf "IMAP user = "
       +read -r imapuser
       +[ $? -gt 0 ] && exit 1
       +rpcfg -c "$profile" imapuser "$imapuser"
       +
       +printf "IMAP password = "
       +read -r imappass
       +[ $? -gt 0 ] && exit 1
       +rpcfg -c "$profile" imappass "$imappass"
       +
       +printf "Sieve configuration.
       +
       +For filtering rohrpost is using remote filters and the Managesieve protocol to
       +edit and create sieve filters. The _rpsieve_ command is responsible for this.
       +If you leave the values empty, sieve will not be used.
       +
       +For the netspec an example would be:
       +        tcp!mail.example.com!4190
       +
       +Sieve does not have an SSL/TLS port defined. So be sure to activate STARTTLS
       +in your managesieve server.\n"
       +
       +printf "Sieve netspec = "
       +read -r sievenet
       +[ $? -gt 0 ] && exit 1
       +rpcfg -c "$profile" sievenet "$sievenet"
       +
       +printf "Sieve user = "
       +read -r sieveuser
       +[ $? -gt 0 ] && exit 1
       +rpcfg -c "$profile" sieveuser "$sieveuser"
       +
       +printf "Sieve password = "
       +read -r sievepass
       +[ $? -gt 0 ] && exit 1
       +rpcfg -c "$profile" sievepass "$sievepass"
       +
       +printf "\nNow I will set some standard values you can change using the
       +_rpcfg -c "$profile"_ command.\n"
       +
       +printf "\nview_msgfilter defines what headers should be shown in the formatted
       +_rpview_ output. Each value is a regexp.
       +
       +view_msgfilter = ^newsgroups,^date,^from,^subject,^to,^cc,^bcc,^reply-to,^organisation,^x-mailer,^user-agent\n"
       +rpcfg -c "$profile" view_msgfilter ^newsgroups,^date,^from,^subject,^to,^cc,^bcc,^reply-to,^organisation,^x-mailer,^user-agent
       +
       +printf "\ndispose = Trash
       +
       +This will tell rohrpost to move all _rprm_ removed e-mails to the 'Trash'
       +folder. Unsetting this _rpcfg -c "$profile"_ key will result in the e-mails being completely
       +removed.\n"
       +rpcfg -c "$profile" dispose Trash
       +
       +printf "\nfold_drafts = Drafts, fold_sent = Sent
       +
       +Those values define into which folder drafts or sent e-mails should be
       +stored.\n"
       +rpcfg -c "$profile" fold_drafts Drafts
       +rpcfg -c "$profile" fold_sent Sent
       +
       +printf "\nsend_cmd = msmtp -t --read-envelope-from
       +
       +Send_cmd defines the command that _rpsend_ will pipe the e-mail to during its
       +invocation. (Sending e-mail.) This msmtp default is reading the From: header
       +and will use its value to determine which SMTP credentials and server to use
       +for the e-mail delivery.\n"
       +rpcfg -c "$profile" send_cmd "msmtp -t --read-envelope-from"
       +
       +printf "\nDo you want the default output templates to be installed for '%s'? (Y/n) " \
       +        "$profile"
       +read -r decision
       +if [ "$decision" != "n" ];
       +then
       +        rpbase="$(rppath -c "$profile" -b)/tmpl"
       +        if [ -d "$shareprefix/tmpl" ];
       +        then
       +                cp -rf $shareprefix/tmpl/* "$rpbase"
       +                chmod 700 $rpbase/*
       +        else
       +                printf "ERROR: $shareprefix/tmpl does not exist for copying over the templates\n"
       +        fi
       +fi
       +
       +printf "\nNow your rohrpost setup is ready!
       +
       +Your first step might be to run _rpinc -nu_ to include the status from your
       +IMAP account to the local database. The -n flag will run a script defined in
       +the _runnotify_ key of the _rpcfg -c "$profile"_ database and the -u flag will
       +generate the 'u' sequence of unread e-mails.
       +
       +If you don't see any output, try _rpinc -a_, which will show you the status of
       +a(ll) folders. You may need to use _rpfold -s_ to show which folders you are
       +subscribed to (and rohrpost will work on). _rpfold -s folder_ will subscribe
       +to the folder.
       +
       +Next you might need to setup msmtp and the advanced topic of local e-mail
       +synchronisation.
       +
       +Have fun!\n"
       +
 (DIR) diff --git a/bin/rpsee b/bin/rpsee
       t@@ -0,0 +1,10 @@
       +#!/bin/sh
       +
       +if [ $# -lt 1 ];
       +then
       +        printf "usage: %s file\n" "$(basename "$0")" >&2
       +        exit 1
       +fi
       +
       +cat "$1" | rpview
       +