Browse Source

POP support added with mpop. Closes #609

tags/3.2.1
Luke Smith 3 years ago
parent
commit
d6d241a5fd
No known key found for this signature in database GPG Key ID: 4C50B54A911F6252
3 changed files with 31 additions and 13 deletions
  1. +4
    -0
      README.md
  2. +15
    -11
      bin/mw
  3. +12
    -2
      mw.1

+ 4
- 0
README.md View File

@@ -63,6 +63,7 @@ A user of Arch-based distros can also install the current mutt-wizard release fr
- `urlview` - outputs urls in mail to browser. - `urlview` - outputs urls in mail to browser.
- `cronie` - (or any other major cronjob manager) to set up automatic mail - `cronie` - (or any other major cronjob manager) to set up automatic mail
syncing. syncing.
- `mpop` - If you want to use POP protocol instead of IMAP.




## Usage ## Usage
@@ -101,6 +102,7 @@ The mutt-wizard runs via the command `mw`. Once setup is complete, you'll use
- `-f` -- Assume mailbox names and force account configuration without - `-f` -- Assume mailbox names and force account configuration without
connecting online at all. connecting online at all.
- `-o` -- Configure mutt for an account, but do not keep mail offline. - `-o` -- Configure mutt for an account, but do not keep mail offline.
- `-P` -- Use POP protocol instead of IMAP (requires `mpop` installed).


## Neomutt user interface ## Neomutt user interface


@@ -163,6 +165,8 @@ To give you an example of the interface, here's an idea:
- Error handling for the many people who don't read or follow directions. Fewer - Error handling for the many people who don't read or follow directions. Fewer
errors generally. errors generally.
- Addition of a manual `man mw` - Addition of a manual `man mw`
- Now handles POP protocol via `mpop` for those who prefer it (add an account
with the `-P` option). POP configs are still generated automatically.


## Help the Project! ## Help the Project!




+ 15
- 11
bin/mw View File

@@ -27,7 +27,7 @@ checkbasics() { command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2"


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 "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;}


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


prepmsmtp() { echo "account $fulladdr prepmsmtp() { echo "account $fulladdr
host $smtp host $smtp
@@ -72,7 +72,8 @@ ExpireUnread no
# End profile # End profile
" >> "$mbsyncrc" ;} " >> "$mbsyncrc" ;}


prepmpop() { echo "
prepmpop() { mkdir -p "${mpoprc%/*}"
echo "
account $fulladdr account $fulladdr
tls on tls on
user $login user $login
@@ -126,6 +127,7 @@ set ssl_starttls = yes
set ssl_force_tls = yes" set ssl_force_tls = yes"
;; ;;
pop) synccmd="macro index o \"<shell-escape>mpop $fulladdr<enter>\" \"run mpop to get $fulladdr's mail\"" pop) synccmd="macro index o \"<shell-escape>mpop $fulladdr<enter>\" \"run mpop to get $fulladdr's mail\""
folder="$maildir/$fulladdr"
prepmpop ;; prepmpop ;;
*) synccmd="macro index o \"<shell-escape>mw -y $fulladdr<enter>\" \"run mbsync to sync $fulladdr\"" *) synccmd="macro index o \"<shell-escape>mw -y $fulladdr<enter>\" \"run mbsync to sync $fulladdr\""
folder="$maildir/$fulladdr" folder="$maildir/$fulladdr"
@@ -152,7 +154,7 @@ EOF


delete() { if [ -z "${fulladdr+x}" ]; then delete() { if [ -z "${fulladdr+x}" ]; then
echo "Select the account your would like to delete (by number):" echo "Select the account your would like to delete (by number):"
list
list || exit 1
read -r input read -r input
match="^$input:" match="^$input:"
else else
@@ -162,18 +164,19 @@ delete() { if [ -z "${fulladdr+x}" ]; then


fulladdr="$(echo "$accounts" | grep "$match" | cut -f2 -d' ')" fulladdr="$(echo "$accounts" | grep "$match" | cut -f2 -d' ')"


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


sed -ibu "/IMAPStore $fulladdr-remote$/,/# End profile/d" "$mbsyncrc" ; 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" rm -rf "${cachedir:?}/${fulladdr:?}" "$accdir/"[1-9]"-$fulladdr.muttrc"
sed -ibu "/[0-9]-$fulladdr.muttrc/d" "$muttrc" ; rm -f "$muttrc"bu
sed -ibu "/account $fulladdr/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu
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" "$mpoprc" 2>/dev/null; rm -f "$mpoprc"bu
pass rm -f "$fulladdr" >/dev/null 2>&1 pass rm -f "$fulladdr" >/dev/null 2>&1
[ -n "${purge+x}" ] && rm -rf "${maildir:?}/${fulladdr:?}" [ -n "${purge+x}" ] && rm -rf "${maildir:?}/${fulladdr:?}"


# Get rid of those multiple newlines because I don't know awk well enough to do it by default lol. # Get rid of those multiple newlines because I don't know awk well enough to do it by default lol.
for file in "$msmtprc" "$mbsyncrc"; do
tr '\n' '|' < "$file" | sed "s/||\+/||/g" | tr '|' '\n' >> "$file"bu
for file in "$msmtprc" "$mbsyncrc" "$mpoprc"; do
tr '\n' '|' < "$file" 2>/dev/null | sed "s/||\+/||/g" | tr '|' '\n' >> "$file"bu
mv -f "$file"bu "$file" mv -f "$file"bu "$file"
done done
} }
@@ -217,13 +220,14 @@ macro index,pager C$1 \";<copy-message>=$3<enter>\" \"copy mail to $2\"" ;}
setBox() { toappend="$toappend setBox() { toappend="$toappend
set $1 = \"+$2\"" ;} set $1 = \"+$2\"" ;}


getboxes() { if [ -n "${force+x}" ]; then
getboxes() { if [ -n "${force+x}" ] ; then
mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")" mailboxes="$(printf "INBOX\\nDrafts\\nJunk\\nTrash\\nSent\\nArchive")"
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 ' ')"
fi fi
[ "$type" = "pop" ] && mailboxes="INBOX"
getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done getaccounts; for x in $(seq 1 9); do echo "$accounts" | grep -q "^$x:" || { export idnum="$x"; break ;}; done
toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )" toappend="mailboxes $(echo "$mailboxes" | sed "s/^/\"=/;s/$/\"/" | paste -sd ' ' - )"
for x in $mailboxes; do for x in $mailboxes; do
@@ -333,7 +337,7 @@ while getopts "fpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in
n) setact add || exit 1 ; realname="$OPTARG" ;; n) setact add || exit 1 ; realname="$OPTARG" ;;
m) setact add || exit 1 ; maxmes="$OPTARG" ;; m) setact add || exit 1 ; maxmes="$OPTARG" ;;
o) setact add || exit 1 ; type="online" ;; o) setact add || exit 1 ; type="online" ;;
P) setact add || exit 1 ; type="pop" ;;
P) setact add || exit 1 ; type="pop"; protocol="pop3s" ; iport="${iport:-995}" ;;
f) setact add || exit 1 ; force=True ;; f) setact add || exit 1 ; force=True ;;
x) setact add || exit 1 ; password="$OPTARG" ;; x) setact add || exit 1 ; password="$OPTARG" ;;
X) setact delete || exit 1 ; purge=True ;; X) setact delete || exit 1 ; purge=True ;;


+ 12
- 2
mw.1 View File

@@ -54,10 +54,10 @@ Real name which will appear in emails. Should be put in quotes if multiple words
Set a maximum number of messages to be stored offline. Set a maximum number of messages to be stored offline.
.TP .TP
.B -i .B -i
IMAP server address
IMAP/POP server address
.TP .TP
.B -I .B -I
IMAP server port (assumed to be 993 if not specified)
IMAP/POP server port (assumed to be 993 for IMAP and 995 for POP if not specified)
.TP .TP
.B -s .B -s
SMTP server address SMTP server address
@@ -86,6 +86,15 @@ When removing an email profile with either
or or
.I -D, .I -D,
also delete the local mail (will not delete the mail on the server). also delete the local mail (will not delete the mail on the server).
.TP
.B -P
Use POP protocol instead of IMAP. Requires
.I mpop
to download mail after configuration. Server details can still be given with the
.I -i
and
.I -I
options as if it were a IMAP.
.SH DETAILS .SH DETAILS
.TP .TP
.B mailsync .B mailsync
@@ -287,6 +296,7 @@ GPLv3
.BR neomutt (1), .BR neomutt (1),
.BR neomuttrc (1) .BR neomuttrc (1)
.BR mbsync (1), .BR mbsync (1),
.BR mpop (1),
.BR msmtp (1), .BR msmtp (1),
.BR notmuch (1), .BR notmuch (1),
.BR abook (1) .BR abook (1)

Loading…
Cancel
Save