From ca9f1a12ccbc01889fd2a1257462594e4d2ea272 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 6 Jan 2021 21:13:48 -0500 Subject: [PATCH] use curl to login rm mbsync requirement for online storage --- README.md | 5 +++-- bin/mw | 17 ++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index fc6999a..46c4a36 100644 --- a/README.md +++ b/README.md @@ -66,9 +66,10 @@ The mutt-wizard is run with the command `mw`. Once everything is setup, you'll u ## Dependencies - `neomutt` - the email client. -- `isync` - downloads and syncs the mail. (required at install) +- `curl` - tests connections (required at install). +- `isync` - downloads and syncs the mail (required if storing IMAP mail locally). - `msmtp` - sends the email. -- `pass` - safely encrypts passwords (required at install) +- `pass` - safely encrypts passwords (required at install). There's a chance of errors if you use a slow-release distro like Ubuntu, Debian or Mint. If you get errors in `neomutt`, install the most recent version manually or manually remove the offending lines in the config in `/usr/share/mutt-wizard/mutt-wizard.muttrc`. diff --git a/bin/mw b/bin/mw index 3586df7..f009e90 100755 --- a/bin/mw +++ b/bin/mw @@ -199,9 +199,8 @@ writeinfo() { mkdir -p "$muttdir" "$accdir" "$cachedir/$fulladdr/bodies" "${XDG_ # On Ubuntu/Debian, a link is needed since they use an older version. command -V apt-get >/dev/null 2>&1 && ln -s "$msmtprc" "$HOME/.msmtprc" 2>/dev/null - # Create the mbsync config file. - mkdir -p "${mbsyncrc%/*}" - echo "$mbsync_profile" >> "$mbsyncrc" + # Create the mbsync config file if local account. + [ -z "${online+x}" ] && mkdir -p "${mbsyncrc%/*}" && echo "$mbsync_profile" >> "$mbsyncrc" # Create a muttrc for viewing mail. echo "$mutt_profile" > "$accdir/$idnum-$fulladdr.muttrc" @@ -230,14 +229,10 @@ Junk Trash Sent Archive" && return 0 - if mailboxes="$(mbsync -l "$fulladdr" | sed 's/\//./')" >/dev/null 2>&1 && [ -n "$mailboxes" ]; then - [ -n "${online+x}" ] && sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; rm -f "$mbsyncrc"bu - return 0 - else - echo "$mailboxes" - echo "Log-on not successful." - return 1 - fi ;} + info="$(curl -s --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap")" || + { echo "Log-on not successful." ; exit 1 ;} + mailboxes="$(echo "$info" | sed "s/.*\" //" | tr -d ' ')" +} finalize() { echo "$mailboxes" | xargs -I {} mkdir -p "$maildir/$fulladdr/{}/cur" "$maildir/$fulladdr/{}/tmp" "$maildir/$fulladdr/{}/new" sed -ibu "/$marker/d" "$accdir/$idnum-$fulladdr.muttrc" ; rm -f "$accdir/$idnum-$fulladdr.muttrcbu"