Browse Source

tests and fixes

pull/276/head
Roland Puntaier 5 years ago
parent
commit
731e4f119c
5 changed files with 51 additions and 44 deletions
  1. +2
    -6
      README.md
  2. +43
    -34
      bin/mw
  3. +1
    -0
      mw.1
  4. +1
    -0
      share/domains.csv
  5. +4
    -4
      test/dotests

+ 2
- 6
README.md View File

@@ -19,12 +19,12 @@ Specifically, this wizard:
## Install and Use ## Install and Use


``` ```
git clone https://github.com/LukeSmithxyz/mutt-wizard
git clone https://github.com/rpuntaie/mutt-wizard
cd mutt-wizard cd mutt-wizard
sudo make install sudo make install
``` ```


User of Arch-based distros can also install mutt-wizard from the AUR as [mutt-wizard-git](https://aur.archlinux.org/packages/mutt-wizard-git/).
User of Arch-based distros can also install mutt-wizard from the AUR as [mw-git](https://aur.archlinux.org/packages/mw-git/).


The mutt-wizard is run with the command `mw`. The mutt-wizard is run with the command `mw`.
Once everything is setup, you'll use `neomutt` to access your mail. Once everything is setup, you'll use `neomutt` to access your mail.
@@ -119,10 +119,6 @@ Look into `/usr/share/mutt-wizard.muttrc` to see all bindings.


- Try mutt-wizard out on weird machines and weird email addresses and report any errors. - Try mutt-wizard out on weird machines and weird email addresses and report any errors.
- Open a PR to add new server information into `domains.csv` so their users can more easily use mutt-wizard. - Open a PR to add new server information into `domains.csv` so their users can more easily use mutt-wizard.
- If nothing else, [Donate!](https://paypal.me/LukeMSmith)

See Luke's website [here](https://lukesmith.xyz).
Email him at [luke@lukesmith.xyz](mailto:luke@lukesmith.xyz).


mutt-wizard is free/libre software, licensed under the GPLv3. mutt-wizard is free/libre software, licensed under the GPLv3.




+ 43
- 34
bin/mw View File

@@ -127,7 +127,7 @@ defaults
auth on auth on
tls on tls on
tls_trust_file $mwsslcert tls_trust_file $mwsslcert
logfile ${XDG_LOG_HOME:-$HOME}/msmtp.log
#logfile ${XDG_LOG_HOME:-$HOME}/msmtp.log
EOF EOF
else else
sed -i "/account $mwaddr/,/^\(\s*$\|account\)/d" "$mwmsmtprc" &>/dev/null sed -i "/account $mwaddr/,/^\(\s*$\|account\)/d" "$mwmsmtprc" &>/dev/null
@@ -198,7 +198,7 @@ path = $mwaccmaildir/INBOX/
[options] [options]
read_all = true read_all = true
delete = true delete = true
message_log = ${XDG_LOG_HOME:-$HOME}/getmail.log
#message_log = ${XDG_LOG_HOME:-$HOME}/getmail.log


# vim: ft=conf # vim: ft=conf
EOF EOF
@@ -209,7 +209,7 @@ _mwprofiles() {
# mutt # mutt
[ ! -f "$mwgenmuttaccs" ] && _mwgenmuttaccs [ ! -f "$mwgenmuttaccs" ] && _mwgenmuttaccs


if [ "$mwtype" = "offline" ]; then
if [ "$mwtype" = "offline" ]; then # not online, actually outside mutt
if [ "${mwkind::3}" = "pop" ]; then if [ "${mwkind::3}" = "pop" ]; then
_mwpop _mwpop
else else
@@ -222,7 +222,7 @@ _mwprofiles() {


_mwtryconnect() { _mwtryconnect() {
if [ ! -d "$mwaccmaildir" ]; then if [ ! -d "$mwaccmaildir" ]; then
mwaccmaildirWasThere="NO" # need to remove again for "online"
[ ! "${mwkind::3}" = "pop" ] && mwaccmaildirWasThere="NO" # mutt uses $mwacccachedir for "online" IMAP, so clean up later
mkdir -p "$mwaccmaildir" mkdir -p "$mwaccmaildir"
fi fi
if [ -z "$mwmailboxes" ]; then if [ -z "$mwmailboxes" ]; then
@@ -232,7 +232,7 @@ _mwtryconnect() {
python -c "from poplib import $mwp;p=$mwp('$mwurl');print(p.getwelcome());p.quit()" | \ python -c "from poplib import $mwp;p=$mwp('$mwurl');print(p.getwelcome());p.quit()" | \
grep "+OK" && mwmailboxes="INBOX" grep "+OK" && mwmailboxes="INBOX"
else else
# for online do without mbsync, as it might not be installed
# for online do without mbsync, i.e. don't require it for mail setup, either
# mwmailboxes="$($mwmbsyncbin -l $mwaddr | sed 's/\//./')" >/dev/null 2>&1 # mwmailboxes="$($mwmbsyncbin -l $mwaddr | sed 's/\//./')" >/dev/null 2>&1
[ "$mwport" = "143" ] && mwi="IMAP4" || mwi="IMAP4_SSL" [ "$mwport" = "143" ] && mwi="IMAP4" || mwi="IMAP4_SSL"
mwpw="$(pass $mwpass)" mwpw="$(pass $mwpass)"
@@ -255,17 +255,21 @@ _mwtryconnect() {


_mwfinalize() { # new mwaccmuttrc _mwfinalize() { # new mwaccmuttrc
if [ "$mwtype" = "online" ]; then if [ "$mwtype" = "online" ]; then
mkdir -p "$mwacccachedir"
sed -i "/IMAPStore $mwaddr-remote$/,/# End mw profile/d" "$mwmbsyncrc" &>/dev/null
if [ ! "${mwkind::3}" = "pop" ]; then
mkdir -p "$mwacccachedir"
fi
fi fi
_mwgenmwaccmuttrc || return 1 _mwgenmwaccmuttrc || return 1
if [ "$mwtype" = "offline" ]; then
if [ "$mwtype" = "offline" ]; then # not online
_mwnotmuchauto _mwnotmuchauto
printf "All done.\\n\033[33mYou can now run \`\033[32mmw [%s]\033[33m\` to sync your mail.\033[0m\\n" "$mwaddr" printf "All done.\\n\033[33mYou can now run \`\033[32mmw [%s]\033[33m\` to sync your mail.\033[0m\\n" "$mwaddr"
elif [ "${mwkind::3}" = "pop" ]; then # and online
_mwnotmuchauto #still usable for online (in mutt) pop
fi fi
if [ "$mwtype" = "online" ]; then if [ "$mwtype" = "online" ]; then
[ "$mwaccmaildirWasThere" = "NO" ] && rm -rf "$mwaccmaildir" &>/dev/null [ "$mwaccmaildirWasThere" = "NO" ] && rm -rf "$mwaccmaildir" &>/dev/null
fi fi
return 0
} }


_mwconfirm() { _mwconfirm() {
@@ -290,7 +294,7 @@ _mwpick() {
_mwdelete() { _mwdelete() {
[ "$mwaccmaildirWasThere" = "NO" ] && rm -rf "$mwaccmaildir" &>/dev/null [ "$mwaccmaildirWasThere" = "NO" ] && rm -rf "$mwaccmaildir" &>/dev/null
rm -f "$mwaccmuttrc" &>/dev/null rm -f "$mwaccmuttrc" &>/dev/null
if [ "$mwtype" = "offline" ]; then
if [ "$mwtype" = "offline" ]; then # not online
sed -i "/${mwaccmuttrc//\//\\\/}/d" "$mwgenmuttaccs" &>/dev/null sed -i "/${mwaccmuttrc//\//\\\/}/d" "$mwgenmuttaccs" &>/dev/null
sed -i "/account $mwaddr/,/^\(\s*$\|account\)/d" "$mwmsmtprc" &>/dev/null sed -i "/account $mwaddr/,/^\(\s*$\|account\)/d" "$mwmsmtprc" &>/dev/null
if [ -f "$mwgetmaildir/$mwaddr" ]; then if [ -f "$mwgetmaildir/$mwaddr" ]; then
@@ -332,7 +336,8 @@ _mwcron() {
_mwasktype() { _mwasktype() {
if [ -z "$mwtype" ]; then if [ -z "$mwtype" ]; then
while : ; do while : ; do
printf "[yes/no]: Local mail via mbsync? 'no' means, that Mutt remotes, which is slower.\\n"
printf "Do you want to sync your mails using the command 'mw' outside mutt? [yes/no]\\n"
printf "'no' makes Neomutt slow for IMAP accounts, so probably you want 'yes'.\\n\t"
read -r mwoffline read -r mwoffline
case "$mwoffline" in case "$mwoffline" in
[Yy][Ee][Ss]) mwtype="offline" && break ;; [Yy][Ee][Ss]) mwtype="offline" && break ;;
@@ -356,7 +361,7 @@ _mwpurge() {
done done
rm -rf "$mwaccmuttdir"/[1-9]-*.muttrc "$mwcachedir" "$mwgenmuttaccs" rm -rf "$mwaccmuttdir"/[1-9]-*.muttrc "$mwcachedir" "$mwgenmuttaccs"
sed -i "/\# mw-autogenerated/d" "$mwmuttrc" sed -i "/\# mw-autogenerated/d" "$mwmuttrc"
pgrep cron >/dev/null && crontab -l | sed '/mw sync/d' | crontab - >/dev/null
crontab -l | sed '/mw sync/d' | crontab - >/dev/null
echo "All configs and account settings have been purged." echo "All configs and account settings have been purged."
} }


@@ -390,11 +395,11 @@ _mwgenmwaccmuttrc() {
mwspoolfile=$(echo "$mwmailboxes" | grep -i -m 1 inbox | sed -ne 's/.*/+\0/p') mwspoolfile=$(echo "$mwmailboxes" | grep -i -m 1 inbox | sed -ne 's/.*/+\0/p')
[ "${mwspoolfile/ /}" = "" ] && return 1 [ "${mwspoolfile/ /}" = "" ] && return 1
mwrecord=$(echo "$mwmailboxes" | grep -i -m 1 sent | sed -ne 's/.*/+\0/p') mwrecord=$(echo "$mwmailboxes" | grep -i -m 1 sent | sed -ne 's/.*/+\0/p')
[ -z "$mwrecord" ] && mkdir -p "$mwaccmaildir/Sent/"{cur,new,tmp} && mwrecord="Sent"
[ -z "$mwrecord" ] && mkdir -p "$mwaccmaildir/Sent/"{cur,new,tmp} && mwrecord="+Sent"
mwpostponed=$(echo "$mwmailboxes" | grep -i -m 1 draft | sed -ne 's/.*/+\0/p') mwpostponed=$(echo "$mwmailboxes" | grep -i -m 1 draft | sed -ne 's/.*/+\0/p')
[ -z "$mwpostponed" ] && mkdir -p "$mwaccmaildir/Drafts/"{cur,new,tmp} && mwpostponed="Drafts"
[ -z "$mwpostponed" ] && mkdir -p "$mwaccmaildir/Drafts/"{cur,new,tmp} && mwpostponed="+Drafts"
mwtrash=$(echo "$mwmailboxes" | grep -i -m 1 trash | sed -ne 's/.*/+\0/p') mwtrash=$(echo "$mwmailboxes" | grep -i -m 1 trash | sed -ne 's/.*/+\0/p')
[ -z "$mwtrash" ] && mkdir -p "$mwaccmaildir/Trash/"{cur,new,tmp} && mwtrash="Trash"
[ -z "$mwtrash" ] && mkdir -p "$mwaccmaildir/Trash/"{cur,new,tmp} && mwtrash="+Trash"
# again to reflect the change # again to reflect the change
mwmailboxes="$(find "$mwaccmaildir/" -name cur | sed "s,$mwaccmaildir/,,g;s,/cur,,")" mwmailboxes="$(find "$mwaccmaildir/" -name cur | sed "s,$mwaccmaildir/,,g;s,/cur,,")"
# find mwaccmuttrc ... # find mwaccmuttrc ...
@@ -411,7 +416,7 @@ _mwgenmwaccmuttrc() {
# link mwaccmuttrc ... # link mwaccmuttrc ...
if [ "$mwtype" = "offline" ]; then if [ "$mwtype" = "offline" ]; then
! grep "source $mwaccmuttrc" "$mwgenmuttaccs" &>/dev/null && echo "source $mwaccmuttrc" >> $mwgenmuttaccs ! grep "source $mwaccmuttrc" "$mwgenmuttaccs" &>/dev/null && echo "source $mwaccmuttrc" >> $mwgenmuttaccs
else
else #online
! grep "source $mwaccmuttrc" "$mwmuttrc" &>/dev/null && echo "source $mwaccmuttrc # mw-autogenerated" >> $mwmuttrc ! grep "source $mwaccmuttrc" "$mwmuttrc" &>/dev/null && echo "source $mwaccmuttrc # mw-autogenerated" >> $mwmuttrc
fi fi
# (re-)generate mwaccmuttrc ... # (re-)generate mwaccmuttrc ...
@@ -438,13 +443,18 @@ EOF
if [ "${mwkind::3}" = "pop" ]; then if [ "${mwkind::3}" = "pop" ]; then
cat >> "$mwaccmuttrc" <<EOF cat >> "$mwaccmuttrc" <<EOF


bind index gc fetch-mail
bind index gm fetch-mail


# pop # pop
set pop_user = "$mwkind://$mwlogin@$mwurl:$mwport"
set pop_pass = `pass magenta.at/roland.puntaier@chello.at`
set pop_host = "\`pass $mwpass\`"
set pop_user = "$mwlogin"
set pop_pass = "\`pass $mwpass\`"
set pop_host = "$mwkind://$mwlogin@$mwurl:$mwport"

set pop_delete = yes set pop_delete = yes

set folder = "$mwaccmaildir"
folder-hook \$folder '$mwmuttsync'

EOF EOF
else # imap else # imap
mwssl=${mwkind/imap/no} mwssl=${mwkind/imap/no}
@@ -468,7 +478,7 @@ EOF
#smtp #smtp
[ "$mwsport" = "25" ] && mwsmtp="smtp" || mwsmtp="smtps" [ "$mwsport" = "25" ] && mwsmtp="smtp" || mwsmtp="smtps"
cat >> "$mwaccmuttrc" <<EOF cat >> "$mwaccmuttrc" <<EOF
set smtp_url = "$mwsmtp://$mwlogin@$mwsmtp:$mwsport"
set smtp_url = "$mwsmtp://$mwlogin@$mwsurl:$mwsport"
EOF EOF
fi #online fi #online
mwboxes="$(echo "$mwmailboxes" | sed -e "s/^ //g;s/.*/\"=\0\"/g" | tr "\n" " ")" mwboxes="$(echo "$mwmailboxes" | sed -e "s/^ //g;s/.*/\"=\0\"/g" | tr "\n" " ")"
@@ -491,12 +501,12 @@ alias me $mwname <$mwaddr>
EOF EOF
IFS=$'\n' IFS=$'\n'
for eqbox in $mwmailboxes; do for eqbox in $mwmailboxes; do
qbox=${eqbox/[/}
b1=${qbox::1}
box=${qbox##*/}
[ "$box" = "$qbox" ] && b2=${qbox:1:1} || b2=${box:1:1}
qbox="${eqbox/\[/}"
b1="${qbox::1}"
box="${qbox##*/}"
[ "$box" = "$qbox" ] && b2="${qbox:1:1}" || b2="${box:1:1}"
boxi="$b1$b2" boxi="$b1$b2"
boxi=${boxi,,}
boxi="${boxi,,}"
cat >> $mwaccmuttrc <<EOF cat >> $mwaccmuttrc <<EOF
macro index,pager i$boxi "<change-folder>=$eqbox<enter>" "go to $eqbox" macro index,pager i$boxi "<change-folder>=$eqbox<enter>" "go to $eqbox"
macro index,pager M$boxi "<save-message>=$eqbox<enter>" "move mail to $eqbox" macro index,pager M$boxi "<save-message>=$eqbox<enter>" "move mail to $eqbox"
@@ -505,6 +515,7 @@ macro index,pager C$boxi "<copy-message>=$eqbox<enter>" "copy mail to $eqbox"
EOF EOF
done done
unset IFS unset IFS
return 0
} }


if [ "$(uname)" = "Darwin" ]; then if [ "$(uname)" = "Darwin" ]; then
@@ -566,9 +577,7 @@ _mwsyncandnotify() {
if [ -f "$mwgetmaildir/$mwaddr" ]; then if [ -f "$mwgetmaildir/$mwaddr" ]; then
$mwgetmailbin --rcfile=$mwaddr --getmaildir=$mwgetmaildir $mwgetmailbin --rcfile=$mwaddr --getmaildir=$mwgetmaildir
else else
tree $mwaccmaildir
$mwmbsyncbin $mwaddr $mwmbsyncbin $mwaddr
tree $mwaccmaildir
fi fi
mwlastrun="$mwaccmaildir/.mw.lastrun" mwlastrun="$mwaccmaildir/.mw.lastrun"
mwnew=$(find "$mwaccmaildir/INBOX/new/" "$mwaccmaildir/Inbox/new/" "$mwaccmaildir/inbox/new/" -type f -newer "$mwlastrun" 2> /dev/null) mwnew=$(find "$mwaccmaildir/INBOX/new/" "$mwaccmaildir/Inbox/new/" "$mwaccmaildir/inbox/new/" -type f -newer "$mwlastrun" 2> /dev/null)
@@ -592,9 +601,8 @@ _mwsyncemails() {
_mwsyncandnotify _mwsyncandnotify
done done
rm $XDG_CONFIG_HOME/getmail/oldmail-* &>/dev/null rm $XDG_CONFIG_HOME/getmail/oldmail-* &>/dev/null
echo notmuch+afew ...
echo notmuch new ...
notmuch new &>/dev/null notmuch new &>/dev/null
# notmuch also created afew MailMover target mailboxes
} }


_mwmuttemails() { _mwmuttemails() {
@@ -688,10 +696,11 @@ else
cron) _mwcron ;; cron) _mwcron ;;
sync) _mwsync ;; sync) _mwsync ;;
*@*) _mwsync $1 ;; *@*) _mwsync $1 ;;
--version|-v) echo "mutt-wizard version 0.9" ;;
--help|-h) cat <<EOF --help|-h) cat <<EOF
mw: mutt-wizard, auto-configure and sync email accounts for mutt, mw: mutt-wizard, auto-configure and sync email accounts for mutt,
including mutt-independent sync of mail with \`isync\` or download of POP3 mail with \`getmail\`. including mutt-independent sync of mail with \`isync\` or download of POP3 mail with \`getmail\`.
Commands: Commands:
add Add and autoconfigure an email address (9 max.) add Add and autoconfigure an email address (9 max.)
ls List configured accounts ls List configured accounts
@@ -700,15 +709,15 @@ else
cron Enable or disable an autosync via cronjob cron Enable or disable an autosync via cronjob
sync sync/download mail based on config in $mwmbsyncrc and $mwgetmaildir sync sync/download mail based on config in $mwmbsyncrc and $mwgetmaildir
--help|-h Print this message --help|-h Print this message
With no parameter all configured emails are synced and all account muttrc's are created. With no parameter all configured emails are synced and all account muttrc's are created.
With a parameter containing a @, an mail is assumed and that account is synced. With a parameter containing a @, an mail is assumed and that account is synced.
Config requirements: Config requirements:
- mbsyncrc: "Path" ends in email - mbsyncrc: "Path" ends in email
- getmail: config file name = email, "path" ends in email - getmail: config file name = email, "path" ends in email
EOF EOF
esac esac




+ 1
- 0
mw.1 View File

@@ -253,6 +253,7 @@ Remember that you can press
at any time in neomutt to get a list of all key-bindings and functions. This list can also vary for different context menus. at any time in neomutt to get a list of all key-bindings and functions. This list can also vary for different context menus.
.SH AUTHORS .SH AUTHORS
Written by Luke Smith <luke@lukesmith.xyz> originally in 2018. Written by Luke Smith <luke@lukesmith.xyz> originally in 2018.
Tests, Bugfixes, Improvements by Roland Puntaier <roland.puntaier@gmail.com> in 2019.
.SH LICENSE .SH LICENSE
GPLv3 GPLv3
.SH SEE ALSO .SH SEE ALSO


+ 1
- 0
share/domains.csv View File

@@ -264,4 +264,5 @@ yandex.net,imap.yandex.com,993,smtp.yandex.com,587
yandex.ru,imap.yandex.com,993,smtp.yandex.com,587 yandex.ru,imap.yandex.com,993,smtp.yandex.com,587
yandex.ua,imap.yandex.com,993,smtp.yandex.com,587 yandex.ua,imap.yandex.com,993,smtp.yandex.com,587
zoho.com,imap.zoho.com,993,smtp.zoho.com,465 zoho.com,imap.zoho.com,993,smtp.zoho.com,465
mailo.com,mail.mailo.com,993,mail.mailo.com,465
chello.at,mail.upcmail.at,995,mail.upcmail.at,465 chello.at,mail.upcmail.at,995,mail.upcmail.at,465

+ 4
- 4
test/dotests View File

@@ -35,8 +35,8 @@ if [ "$OK" = "OK" ]; then


echo "= Test 1 =" echo "= Test 1 ="
mwtype=online mw add mwtype=online mw add
echo "=> In another window, start mutt and verify that mails are shown"
echo "=> Then anwer with N"
echo "=> In another prompt, start mutt and verify that mails are shown"
echo "=> Then answer with N"
mw purge mw purge
rm -rf $mwaccmaildir rm -rf $mwaccmaildir


@@ -44,10 +44,10 @@ if [ "$OK" = "OK" ]; then
mwtype=offline mw add mwtype=offline mw add
mw mw


echo "=> In another window, start mutt and verify that mails are shown"
echo "=> In another prompt, start mutt and verify that mails are shown"
echo "=> Press i1, wait, press i2. Verify that mutt is fast again after i2." echo "=> Press i1, wait, press i2. Verify that mutt is fast again after i2."
echo "=> Press gm and gM, to start mw sync." echo "=> Press gm and gM, to start mw sync."
echo "=> Anwer with Y and check that mbsyncrc, msmtp/config and mutt/accounts are gone."
echo "=> Answer with Y and check that mbsyncrc, msmtp/config and mutt/accounts are gone."
mw purge mw purge


fi fi


Loading…
Cancel
Save