printf "Insert the \033[31memail address\033[0m that you want to autoconfigure for mutt/offlineIMAP\\n\\nEmail: "
printf "\033[36m\t"
read -r fulladdr
printf "\033[0m"
while ! echo "$fulladdr" | grep "$emailre" >/dev/null; do
printf "That is not a valid \033[31memail address\033[0m, please retype the desired email.\\n\\nEmail: "
printf "\033[36m\t"
read -r fulladdr
printf "\033[0m"
done
domain="$(echo "$fulladdr" | sed "s/.*@//")"
printf "\\nSearching for \033[32m%s\033[0m in \033[34m\`domains.csv\`\033[0m..." "$domain"
@@ -102,13 +106,21 @@ addaccount() { \
if [ -z "$serverinfo" ]; then
printf "Your email domain is not in mutt-wizard's database yet.\\nmutt-wizard will still autoconfigure everything, but you will have to manually type in your service's IMAP and SMTP server information.\\nYou can usually quickly find this by internet searching for it.\\n"
printf "Insert the IMAP server for your email provider (excluding the port number)\\n"
printf "\033[36m\t"
read -r imap
printf "\033[0m"
printf "What is your server's IMAP port number? (Usually something like 993)\\n"
printf "\033[36m\t"
read -r iport
printf "\033[0m"
printf "Insert the SMTP server for your email provider (excluding the port number)\\n"
printf "\033[36m\t"
read -r smtp
printf "\033[0m"
printf "What is your server's SMTP port number? (Usually 587 or 465)\\n"
printf "\033[36m\t"
read -r sport
printf "\033[0m"
printf "\\nGreat! If you want to be helpful, copy the line below and you can add it to the \`domains.csv\` file on Github.\\nThis will make things easier for others who use your email provider.\\n\\n%s,%s,%s,%s,%s\\n\\nAlthough be sure to test to see if these settings work first! ;-)\\n" "$domain" "$imap" "$iport" "$smtp" "$sport"
else
IFS=, read -r service imap iport smtp sport <<EOF
@@ -126,10 +138,14 @@ EOF
read -r title
while ! echo "$title" | grep "$namere" >/dev/null; do
printf "\033[31mTry again\033[0m. Pick a nickname that is one word only including lowercase letters and _ or -.\\n\tAccount name: "
printf "\033[36m\t"
read -r title
printf "\033[0m"
done
printf "If your account has a special username different from your address, insert it now. Otherwise leave this prompt totally blank.\\n\tLogin(?): "
printf "\033[36m\t"
read -r login
printf "\033[0m"
[ -z "$login" ] && login="$fulladdr"
if [ "$service" = "gmail.com" ]; then
type="Gmail"; ifgoogleline="folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail']"
printf "Now enter your password for the \"%s\" account. Don't worry, this will be encrypted and only you with your GPG key can view it.\\n\tPassword: " "$1"
printf "Now enter your password for the \"%s\" account. Don't worry, this will be encrypted and only you with your GPG key can view it.\\n\tPassword: " "$title"
stty -echo
read -r password
stty echo
echo "$password" > "$tmpdir/$1"
echo "$password" > "$tmpdir/$title"
printf "Encrypting your password with %s..." "$GPG"
"$GPG" -r "$gpgemail" --encrypt "$tmpdir/$1"
"$GPG" -r "$gpgemail" --encrypt "$tmpdir/$title"
printf "DONE\\nShredding all memory of your password for safety's sake..."
unset password
shred -u "$tmpdir/$1" #| rm -f "$tmpdir/$1"
shred -u "$tmpdir/$title"
mkdir -p "$creddir"
mv "$tmpdir/$1.gpg" "$creddir/"
mv "$tmpdir/$title.gpg" "$creddir/"
printf "DONE.\\n"
}
askgpg() { \
printf "To safely encrypt passwords, mutt-wizard requires that you have a GPG public/private key pair.\\n\\nPlease input the email address of your GPG key pair below.\\nEmail: "
printf "\033[36m\t"
read -r gpgemail
printf "\033[0m"
while ! echo "$gpgemail" | grep "$emailre" >/dev/null; do
printf "That is not a valid email address. Please try again.\\nEmail: "
printf "\033[36m\t"
read -r gpgemail
printf "\033[0m"
done
if "$GPG" -K | grep "<$gpgemail>" >/dev/null; then
mkdir -p "$creddir"
@@ -193,14 +213,6 @@ formatShortcut() { \
echo "macro index,pager C$1 \"<copy-message>$data<enter>\" \"Copy mail to $2.\" # autogenerated"; } >> "$muttdir/accounts/$3.muttrc"
done ;}
gen_delim() { \
delim="="
for i in $(seq $(( $1 - 1 )))
do
delim="$delim-"
done
echo $delim ;}
trysync() { \
! ping -q -c 1 1.1.1.1 > /dev/null && printf "No internet connection detected.\\nTry rerunning offlineimap manually when connection is established, then select the option to detect mailboxes and finalize installation.\\n" && return 1
printf "\033[32mYou must have an internet connection to continue.\033[0m\\nmutt-wizard will run offlineimap briefly to (1) ensure that login details are functional and (2) allow offlineimap to tell us what mailboxes your email account has.\\nAfter around 15 seconds, mutt-wizard will kill the process and continue.\\nYou can run offlineimap manually to finish the mail sync later.\\nPress enter to continue.\\n."