From ae310a18f7f54fe4c5ab8cf6fca903934b3b69bc Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Mon, 6 Jan 2020 10:55:00 +0530 Subject: [PATCH] Update all mail related configs 1. Use app password for gmail accounts 2. Add nilenso account to mutt, imapfilter, mbsync, msmtp Signed-off-by: Sanchayan Maity --- imapfilter/.imapfilter/config.lua | 46 +++++++++++++++++++------------ mbsync/.mbsyncrc | 42 ++++++++++++++++++---------- msmtp/.msmtprc | 6 ++++ mutt/.mutt/accounts/nilenso | 15 ++++++++++ mutt/.mutt/accounts/sanchayan | 4 +-- mutt/.mutt/mailnotify.sh | 13 +++++---- mutt/.mutt/muttrc | 15 +++++----- notmuch/.notmuch-config | 6 ++-- 8 files changed, 96 insertions(+), 51 deletions(-) create mode 100644 mutt/.mutt/accounts/nilenso diff --git a/imapfilter/.imapfilter/config.lua b/imapfilter/.imapfilter/config.lua index 323639e..18417aa 100644 --- a/imapfilter/.imapfilter/config.lua +++ b/imapfilter/.imapfilter/config.lua @@ -6,37 +6,41 @@ function main() ssl = 'tls1', } - -- Make sure the account is configured properly sanchayan.INBOX:check_status() -- sanchayan['[Gmail]/Trash']:check_status() -- sanchayan['[Gmail]/Spam']:check_status() - - -- Get all mail from INBOX mails = sanchayan.INBOX:select_all() - - -- Move mailing lists from INBOX to correct folders move_mailing_lists(sanchayan, mails) - - -- Get all mail from Sent Mail mails = sanchayan.Sent:select_all() - - -- Move mailing lists from Sent mail to correct folders move_mailing_lists(sanchayan, mails) - - -- Get all mail from trash mails = sanchayan['[Gmail]/Trash']:select_all() imap_trash = sanchayan['Trash']:select_all() - - -- Move mailing lists from trash to correct folders move_to_gmail_trash(sanchayan, imap_trash, '[Gmail]/Trash') delete_from_trash(sanchayan, mails) - - -- Get all mail from spam mails = sanchayan['[Gmail]/Spam']:select_all() - - -- Move mailing lists from spam to correct folders move_mailing_lists(sanchayan, mails) + local nilenso = IMAP { + server = 'imap.gmail.com', + username = 'sanchayan@nilenso.systems', + password = get_pwd_nilenso(), + ssl = 'tls1', + } + + nilenso.INBOX:check_status() + -- nilenso['[Gmail]/Trash']:check_status() + -- nilenso['[Gmail]/Spam']:check_status() + mails = nilenso.INBOX:select_all() + move_mailing_lists(nilenso, mails) + mails = nilenso.Sent:select_all() + move_mailing_lists(nilenso, mails) + mails = nilenso['[Gmail]/Trash']:select_all() + imap_trash = nilenso['Trash']:select_all() + move_to_gmail_trash(nilenso, imap_trash, '[Gmail]/Trash') + delete_from_trash(nilenso, mails) + mails = nilenso['[Gmail]/Spam']:select_all() + move_mailing_lists(nilenso, mails) + end function move_mailing_lists(account, mails) @@ -125,4 +129,12 @@ function get_pwd_sanchayan() return pass; end +function get_pwd_nilenso() + local cmd = "gpg2 --use-agent --quiet --batch --decrypt ~/.nilenso.gpg" + local fd = io.popen(cmd, 'r') + pass = fd:read("*a") + fd:close() + return pass; +end + main() -- Call the main function diff --git a/mbsync/.mbsyncrc b/mbsync/.mbsyncrc index 59b8d47..0af71f7 100644 --- a/mbsync/.mbsyncrc +++ b/mbsync/.mbsyncrc @@ -1,13 +1,33 @@ +Create Slave +Expunge Both +SyncState * + +IMAPAccount nilenso +Host imap.gmail.com +Port 993 +User sanchayan@nilenso.systems +PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.nilenso.gpg" +SSLType IMAPS +CertificateFile /etc/ssl/certs/ca-certificates.crt + +IMAPStore nilenso-remote +Account nilenso + +MaildirStore nilenso-local +SubFolders Verbatim +Path "~/Gmail/nilenso/" +Inbox "~/Gmail/nilenso/Inbox" + +Channel nilenso +Master :nilenso-remote: +Slave :nilenso-local: +Patterns * ![Gmail]* "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail" + IMAPAccount gmail -# Address to connect to Host imap.gmail.com User maitysanchayan@gmail.com -# To store the password in an encrypted file use PassCmd instead of Pass PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.sanchayan.gpg" -# -# Use SSL SSLType IMAPS -# The following line should work. If get certificate errors, uncomment the two following lines and read the "Troubleshooting" section. CertificateFile /etc/ssl/certs/ca-certificates.crt IMAPStore gmail-remote @@ -15,18 +35,10 @@ Account gmail MaildirStore gmail-local Subfolders Verbatim -# The trailing "/" is important -Path ~/Gmail/ -Inbox ~/Gmail/Inbox +Path "~/Gmail/sanchayan/" +Inbox "~/Gmail/sanchayan/Inbox" Channel gmail Master :gmail-remote: Slave :gmail-local: -# Exclude everything under the internal [Gmail] folder, except the interesting folders Patterns * ![Gmail]* "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail" -# Or include everything -#Patterns * -# Automatically create missing mailboxes, both locally and on the server -Create Both -# Save the synchronization state files in the relevant directory -SyncState * diff --git a/msmtp/.msmtprc b/msmtp/.msmtprc index c0f9766..05490da 100644 --- a/msmtp/.msmtprc +++ b/msmtp/.msmtprc @@ -13,5 +13,11 @@ from maitysanchayan@gmail.com user maitysanchayan@gmail.com passwordeval "gpg2 --use-agent --batch --quiet --no-greeting --no-tty --for-your-eyes-only --homedir /home/core/.gnupg --decrypt ~/.sanchayan.gpg" +account nilenso +host smtp.gmail.com +from sanchayan@nilenso.systems +user sanchayan@nilenso.systems +passwordeval "gpg2 --use-agent --batch --quiet --no-greeting --no-tty --for-your-eyes-only --homedir /home/core/.gnupg --decrypt ~/.nilenso.gpg" + # Set a default account account default : Sanchayan diff --git a/mutt/.mutt/accounts/nilenso b/mutt/.mutt/accounts/nilenso new file mode 100644 index 0000000..b82a38b --- /dev/null +++ b/mutt/.mutt/accounts/nilenso @@ -0,0 +1,15 @@ +set from = "sanchayan@nilenso.systems" +set sendmail = "/usr/bin/msmtp -a nilenso" +set mbox = "+Archive" +set postponed = "+drafts" +set record = "+Sent" + +color status green default + +macro index D \ + "+nilenso/Trash" \ + "move message to the trash" + +macro index S \ + "+nilenso/Spam" \ + "mark message as spam" diff --git a/mutt/.mutt/accounts/sanchayan b/mutt/.mutt/accounts/sanchayan index 8612537..9bd4ec6 100644 --- a/mutt/.mutt/accounts/sanchayan +++ b/mutt/.mutt/accounts/sanchayan @@ -7,9 +7,9 @@ set record = "+Sent" color status green default macro index D \ - "+Trash" \ + "+sanchayan/Trash" \ "move message to the trash" macro index S \ - "+Spam" \ + "+sanchayan/Spam" \ "mark message as spam" diff --git a/mutt/.mutt/mailnotify.sh b/mutt/.mutt/mailnotify.sh index adb743e..0299d83 100755 --- a/mutt/.mutt/mailnotify.sh +++ b/mutt/.mutt/mailnotify.sh @@ -1,14 +1,15 @@ #!/bin/bash -imapfilter -c /home/core/.imapfilter/config.lua -mbsync -Va +imapfilter -c ~/.imapfilter/config.lua +mbsync -a notmuch new export DISPLAY=:0 -let inbox=`ls /home/core/Mail/Inbox/new/|wc -l` +let inbox=`ls /home/core/Gmail/sanchayan/Inbox/new/|wc -l` +let nilenso_inbox=`ls /home/core/Gmail/nilenso/Inbox/new/|wc -l` -if (("$inbox" > 0)); then - sudo -u core DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "You have -$inbox new mails in Inbox" +if (("$inbox" > 0) || ("$nilenso_inbox" > 0)); then + sudo -u core DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "You have $inbox new mails in inbox" + sudo -u core DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "You have $nilenso_inbox new mails in Nilenso inbox" fi diff --git a/mutt/.mutt/muttrc b/mutt/.mutt/muttrc index 05b648d..3737513 100644 --- a/mutt/.mutt/muttrc +++ b/mutt/.mutt/muttrc @@ -1,11 +1,13 @@ set mbox_type = Maildir - -set spoolfile = "+Inbox" +set folder = ~/Gmail +set spoolfile = +/sanchayan/Inbox +set header_cache=~/Gmail/mutt_cache/ # a much faster opening of mailboxes... source ~/.mutt/accounts/sanchayan +source ~/.mutt/accounts/nilenso -folder-hook Sanchayan/* source ~/.mutt/accounts/sanchayan -#folder-hook Victor/* source ~/.mutt/accounts/victor +folder-hook sanchayan/* source ~/.mutt/accounts/sanchayan +folder-hook nilenso/* source ~/.mutt/accounts/nilenso set mail_check = 0 set envelope_from @@ -73,7 +75,4 @@ macro index L "unset wait_keyread -p 'notmuc # 'a' shows all messages again (supersedes default binding) macro index a "all\n" "show all messages (undo limit)" -set header_cache=~/Gmail/mutt_cache/ # a much faster opening of mailboxes... - -macro index D "+/Trash" "Move message to the trash" - +# macro index D "+/Trash" "Move message to the trash" diff --git a/notmuch/.notmuch-config b/notmuch/.notmuch-config index 25fdceb..993aec1 100644 --- a/notmuch/.notmuch-config +++ b/notmuch/.notmuch-config @@ -11,7 +11,7 @@ # configured here named ".notmuch". # [database] -path=/home/core/Mail +path=/home/core/Gmail # User configuration # @@ -30,8 +30,8 @@ path=/home/core/Mail # [user] name=Sanchayan Maity -primary_email=maitysanchayan@gmail.com -other_email=victorascroft@gmail.com; +primary_email=sanchayan@nilenso.systems +other_email=maitysanchayan@gmail.com; # Configuration for "notmuch new" #