jaromail

a commandline tool to easily and privately handle your e-mail
git clone git://parazyd.org/jaromail.git
Log | Files | Refs | Submodules | README

commit fb4254b2ca8a6c443f2a7ebe136f15405025ea08
parent 21d2c808587776b6c9c6b5357c79a3e43c8593c7
Author: Jaromil <jaromil@dyne.org>
Date:   Tue, 18 Apr 2017 09:43:47 +0200

'new' command to quickly create new account templates from emails

Diffstat:
Msrc/jaro | 6++++++
Msrc/zlibs/accounts | 49+++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/src/jaro b/src/jaro @@ -506,6 +506,7 @@ main() { option_subcommands[export]="" option_subcommands[vcard]="" option_subcommands[abook]="" + option_subcommands[new]="" option_subcommands[vim]="" option_subcommands[edit]="" @@ -679,6 +680,11 @@ main() { exitcode=$? ;; + new) + new_account ${option_params} + exitcode=$? + ;; + stat*) stats ${option_params} | sort -n exitcode=$? ;; diff --git a/src/zlibs/accounts b/src/zlibs/accounts @@ -20,6 +20,55 @@ # this source code; if not, write to: # Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +new_account() { + fn new_account $* + acct=$1 + req=(acct) + ckreq || return 1 + + [[ -r $MAILDIRS/Accounts/$acct ]] && { + error "account already existing: $MAILDIRS/Accounts/$acct" + return 1 } + + isemail $acct || { + error "new account is not an email: $acct" + return 1 } + + + name=${acct%%@*} + domain=${acct##*@} + local options + case $domain in + gmail.com) + imap=imap.gmail.com + smtp=smtp.gmail.com + auth=plain + cert=check + options=keep + ;; + *) + imap=mail.${domain} + smtp=mail.${domain} + auth=plain + cert=check + options=keep + ;; + esac + cat <<EOF > $MAILDIRS/Accounts/$acct +# automatically generated by 'jaro new' for account: $acct +# modifications will not be overwritten +name $name +email $acct +login $acct +imap $imap +smtp $smtp +auth $auth +cert $cert +options $options +EOF + act "account succesfully generated for $acct" + return 1 +} # account = type.name es: imap.default or smtp.gmail # -a defines which account name other than 'default'