5 Commits

Author SHA1 Message Date
  Luke Smith b6f0bd4426
more computationally efficient idnum discovery 2 years ago
  Luke Smith a3fc13e5ce
465 now default instead of 587 2 years ago
  Luke Smith 7a792c7c11
actual lol 2 years ago
  Luke Smith 8c668a22e0
lol 2 years ago
  Luke Smith fcf4ba52c3
id numbers removed from filenames 2 years ago
4 changed files with 21 additions and 19 deletions
Unified View
  1. +1
    -1
      README.md
  2. +18
    -16
      bin/mw
  3. +1
    -1
      mw.1
  4. +1
    -1
      share/domains.csv

+ 1
- 1
README.md View File

@@ -91,7 +91,7 @@ The mutt-wizard runs via the command `mw`. Once setup is complete, you'll use
- `-i` -- IMAP server address - `-i` -- IMAP server address
- `-I` -- IMAP server port (otherwise assumed to be 993) - `-I` -- IMAP server port (otherwise assumed to be 993)
- `-s` -- SMTP server address - `-s` -- SMTP server address
- `-S` -- SMTP server port (otherwise assumed to be 587)
- `-S` -- SMTP server port (otherwise assumed to be 465)
- `-m` -- Maximum number of emails to be kept offline. No maximum is default - `-m` -- Maximum number of emails to be kept offline. No maximum is default
functionality. functionality.
- `-x` -- Account password. You will be prompted for it otherwise. - `-x` -- Account password. You will be prompted for it otherwise.


+ 18
- 16
bin/mw View File

@@ -34,13 +34,13 @@ checkbasics() { command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2"
echo "(If you don't already have a GPG key pair, first run \`$GPG --full-generate-key\`.)" echo "(If you don't already have a GPG key pair, first run \`$GPG --full-generate-key\`.)"
exit 1 ;} ;} exit 1 ;} ;}


getaccounts() { accounts="$(find -L "$accdir" -type f 2>/dev/null | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;}
getaccounts() { accounts="$(find -L "$accdir" -type f 2>/dev/null | grep -o "\S*.muttrc" | sed "s|.*/\([0-9]-\)*||;s/\.muttrc$//" | nl)" ;}


list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" || exit 1 ;} list() { getaccounts && [ -n "$accounts" ] && echo "$accounts" || exit 1 ;}


prepmsmtp() { echo "account $fulladdr prepmsmtp() { echo "account $fulladdr
host $smtp host $smtp
port ${sport:-587}
port ${sport:-465}
from $fulladdr from $fulladdr
user $login user $login
passwordeval \"pass $fulladdr\" passwordeval \"pass $fulladdr\"
@@ -48,7 +48,7 @@ auth ${auth:-on}
tls on tls on
tls_trust_file $sslcert tls_trust_file $sslcert
logfile $msmtplog logfile $msmtplog
$tlsline
${tlsline:-tls_starttls off}
" >> "$msmtprc" " >> "$msmtprc"
} }


@@ -104,12 +104,12 @@ set hostname = \"$hostname\"
source $muttshare/unbind.muttrc source $muttshare/unbind.muttrc
$extra $extra
$synccmd $synccmd
" > "$accdir/$idnum-$fulladdr.muttrc"
" > "$accdir/$fulladdr.muttrc"


[ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc" [ ! -f "$muttrc" ] && echo "# vim: filetype=neomuttrc" > "$muttrc"
! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $muttshare/mutt-wizard.muttrc" >> "$muttrc" ! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $muttshare/mutt-wizard.muttrc" >> "$muttrc"
! grep "^source.*.muttrc" "$muttrc" | grep -qv "$muttshare/mutt-wizard.muttrc" && echo "source $accdir/$idnum-$fulladdr.muttrc" >> "$muttrc"
echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$idnum-$fulladdr.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\"" >> "$muttrc"
! grep "^source.*.muttrc" "$muttrc" | grep -qv "$muttshare/mutt-wizard.muttrc" && echo "source $accdir/$fulladdr.muttrc" >> "$muttrc"
echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$fulladdr.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\"" >> "$muttrc"
} }


getprofiles() { \ getprofiles() { \
@@ -156,19 +156,19 @@ delete() { if [ -z "${fulladdr+x}" ]; then
echo "Select the account you would like to delete (by number):" echo "Select the account you would like to delete (by number):"
list || exit 1 list || exit 1
read -r input read -r input
match="^$input:"
match="^\s*$input\s\+"
else else
match=" $fulladdr$"
match="\s\+$fulladdr$"
getaccounts getaccounts
fi fi


fulladdr="$(echo "$accounts" | grep "$match" | cut -f2 -d' ')"
fulladdr="$(echo "$accounts" | grep "$match" | grep -o "\S*@\S*")"


[ -z "$fulladdr" ] && echo "$fulladdr is not a valid account name." && return 1 [ -z "$fulladdr" ] && echo "$fulladdr is not a valid account name." && return 1


sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" 2>/dev/null ; rm -f "$mbsyncrc"bu sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" 2>/dev/null ; rm -f "$mbsyncrc"bu
rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/"[1-9]"-$fulladdr.muttrc"
sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu
rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/$fulladdr.muttrc" "$accdir/"[0-9]-"$fulladdr.muttrc"
sed -ibu "/\([0-9]-\)\?$fulladdr.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu
sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$msmtprc" 2>/dev/null; rm -f "$msmtprc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$msmtprc" 2>/dev/null; rm -f "$msmtprc"bu
sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$mpoprc" 2>/dev/null; rm -f "$mpoprc"bu sed -ibu "/account $fulladdr$/,/^\(\s*$\|account\)/d" "$mpoprc" 2>/dev/null; rm -f "$mpoprc"bu
pass rm -f "$fulladdr" >/dev/null 2>&1 pass rm -f "$fulladdr" >/dev/null 2>&1
@@ -193,7 +193,7 @@ askinfo() { \
read -r imap read -r imap
[ -z "$smtp" ] && echo "Give your email server's SMTP address (excluding the port number):" && [ -z "$smtp" ] && echo "Give your email server's SMTP address (excluding the port number):" &&
read -r smtp read -r smtp
[ "$sport" = 465 ] && tlsline="tls_starttls off"
[ "$sport" = 587 ] && tlsline="# tls_starttls"
[ -z "$realname" ] && realname="${fulladdr%%@*}" [ -z "$realname" ] && realname="${fulladdr%%@*}"
hostname="$(echo "$fulladdr" | cut -d @ -f 2)" hostname="$(echo "$fulladdr" | cut -d @ -f 2)"
login="${login:-$fulladdr}" login="${login:-$fulladdr}"
@@ -224,11 +224,13 @@ getboxes() { if [ -n "${force+x}" ] ; then
else else
info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")" info="$(curl --location-trusted -s -m 5 --user "$login:$(pass "$fulladdr")" --url "${protocol:-imaps}://$imap:${iport:-993}")"
[ -z "$info" ] && echo "Log-on not successful." && return 1 [ -z "$info" ] && echo "Log-on not successful." && return 1
mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '
')"
mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')"
fi fi
[ "$type" = "pop" ] && mailboxes="INBOX" [ "$type" = "pop" ] && mailboxes="INBOX"
getaccounts; for x in 1 2 3 4 5 6 7 8 9; do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done
for x in $(sed -n "/^macro.* i[0-9] / s/\(^macro.* i\| .*\)//gp " $muttrc | sort -u; echo 0); do
idnum=$((idnum + 1))
[ $idnum -eq $x ] || break
done
toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -mindepth 1 -type d -name cur | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | sort | tr '\\\n' ' '\`" toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -mindepth 1 -type d -name cur | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | sort | tr '\\\n' ' '\`"
IFS=' IFS='
' '
@@ -246,7 +248,7 @@ getboxes() { if [ -n "${force+x}" ] ; then
unset IFS unset IFS
} }


finalize() { echo "$toappend" >> "$accdir/$idnum-$fulladdr.muttrc"
finalize() { echo "$toappend" >> "$accdir/$fulladdr.muttrc"
[ "$type" != "online" ] && echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" [ "$type" != "online" ] && echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new"
echo "$fulladdr (account #$idnum) added successfully." echo "$fulladdr (account #$idnum) added successfully."
command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview" command -V urlview >/dev/null 2>&1 && [ ! -f "$HOME/.urlview" ] && echo "COMMAND \$BROWSER" > "$HOME/.urlview"


+ 1
- 1
mw.1 View File

@@ -63,7 +63,7 @@ IMAP/POP server port (assumed to be 993 for IMAP and 995 for POP if not specifie
SMTP server address SMTP server address
.TP .TP
.B -S .B -S
SMTP server port (assumed to be 587 if not specified)
SMTP server port (assumed to be 465 if not specified)
.TP .TP
.B -x .B -x
Account password. You will be prompted for the password interactively if this option is not given. Account password. You will be prompted for the password interactively if this option is not given.


+ 1
- 1
share/domains.csv View File

@@ -160,7 +160,7 @@ live.rhul.ac.uk,outlook.office365.com,993,smtp.office365.com,587
logorroici.org,mail.autistici.org,993,smtp.autistici.org,465 logorroici.org,mail.autistici.org,993,smtp.autistici.org,465
loves.dicksinhisan.us,mail.cock.li,993,mail.cock.li,587 loves.dicksinhisan.us,mail.cock.li,993,mail.cock.li,587
loves.dicksinmyan.us,mail.cock.li,993,mail.cock.li,587 loves.dicksinmyan.us,mail.cock.li,993,mail.cock.li,587
lukesmith.xyz,mail.lukesmith.xyz,993,mail.lukesmith.xyz,587
lukesmith.xyz,mail.lukesmith.xyz,993,mail.lukesmith.xyz,465
luther.edu,imap.gmail.com,993,smtp.gmail.com,587 luther.edu,imap.gmail.com,993,smtp.gmail.com,587
mac.com,imap.mail.me.com,993,smtp.mail.me.com,587 mac.com,imap.mail.me.com,993,smtp.mail.me.com,587
mace.ac.in,imap.gmail.com,993,smtp.gmail.com,587 mace.ac.in,imap.gmail.com,993,smtp.gmail.com,587


Loading…
Cancel
Save