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 <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2020-01-06 10:55:00 +05:30
parent f4ced7432d
commit ae310a18f7
8 changed files with 96 additions and 51 deletions

View file

@ -6,37 +6,41 @@ function main()
ssl = 'tls1', ssl = 'tls1',
} }
-- Make sure the account is configured properly
sanchayan.INBOX:check_status() sanchayan.INBOX:check_status()
-- sanchayan['[Gmail]/Trash']:check_status() -- sanchayan['[Gmail]/Trash']:check_status()
-- sanchayan['[Gmail]/Spam']:check_status() -- sanchayan['[Gmail]/Spam']:check_status()
-- Get all mail from INBOX
mails = sanchayan.INBOX:select_all() mails = sanchayan.INBOX:select_all()
-- Move mailing lists from INBOX to correct folders
move_mailing_lists(sanchayan, mails) move_mailing_lists(sanchayan, mails)
-- Get all mail from Sent Mail
mails = sanchayan.Sent:select_all() mails = sanchayan.Sent:select_all()
-- Move mailing lists from Sent mail to correct folders
move_mailing_lists(sanchayan, mails) move_mailing_lists(sanchayan, mails)
-- Get all mail from trash
mails = sanchayan['[Gmail]/Trash']:select_all() mails = sanchayan['[Gmail]/Trash']:select_all()
imap_trash = sanchayan['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') move_to_gmail_trash(sanchayan, imap_trash, '[Gmail]/Trash')
delete_from_trash(sanchayan, mails) delete_from_trash(sanchayan, mails)
-- Get all mail from spam
mails = sanchayan['[Gmail]/Spam']:select_all() mails = sanchayan['[Gmail]/Spam']:select_all()
-- Move mailing lists from spam to correct folders
move_mailing_lists(sanchayan, mails) 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 end
function move_mailing_lists(account, mails) function move_mailing_lists(account, mails)
@ -125,4 +129,12 @@ function get_pwd_sanchayan()
return pass; return pass;
end 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 main() -- Call the main function

View file

@ -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 IMAPAccount gmail
# Address to connect to
Host imap.gmail.com Host imap.gmail.com
User maitysanchayan@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" PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.sanchayan.gpg"
#
# Use SSL
SSLType IMAPS 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 CertificateFile /etc/ssl/certs/ca-certificates.crt
IMAPStore gmail-remote IMAPStore gmail-remote
@ -15,18 +35,10 @@ Account gmail
MaildirStore gmail-local MaildirStore gmail-local
Subfolders Verbatim Subfolders Verbatim
# The trailing "/" is important Path "~/Gmail/sanchayan/"
Path ~/Gmail/ Inbox "~/Gmail/sanchayan/Inbox"
Inbox ~/Gmail/Inbox
Channel gmail Channel gmail
Master :gmail-remote: Master :gmail-remote:
Slave :gmail-local: Slave :gmail-local:
# Exclude everything under the internal [Gmail] folder, except the interesting folders
Patterns * ![Gmail]* "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail" 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 *

View file

@ -13,5 +13,11 @@ from maitysanchayan@gmail.com
user 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" 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 # Set a default account
account default : Sanchayan account default : Sanchayan

View file

@ -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 \
"<save-message>+nilenso/Trash<enter>" \
"move message to the trash"
macro index S \
"<save-message>+nilenso/Spam<enter>" \
"mark message as spam"

View file

@ -7,9 +7,9 @@ set record = "+Sent"
color status green default color status green default
macro index D \ macro index D \
"<save-message>+Trash<enter>" \ "<save-message>+sanchayan/Trash<enter>" \
"move message to the trash" "move message to the trash"
macro index S \ macro index S \
"<save-message>+Spam<enter>" \ "<save-message>+sanchayan/Spam<enter>" \
"mark message as spam" "mark message as spam"

View file

@ -1,14 +1,15 @@
#!/bin/bash #!/bin/bash
imapfilter -c /home/core/.imapfilter/config.lua imapfilter -c ~/.imapfilter/config.lua
mbsync -Va mbsync -a
notmuch new notmuch new
export DISPLAY=:0 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 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 sudo -u core DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "You have $inbox new mails in inbox"
$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 fi

View file

@ -1,11 +1,13 @@
set mbox_type = Maildir set mbox_type = Maildir
set folder = ~/Gmail
set spoolfile = "+Inbox" set spoolfile = +/sanchayan/Inbox
set header_cache=~/Gmail/mutt_cache/ # a much faster opening of mailboxes...
source ~/.mutt/accounts/sanchayan source ~/.mutt/accounts/sanchayan
source ~/.mutt/accounts/nilenso
folder-hook Sanchayan/* source ~/.mutt/accounts/sanchayan folder-hook sanchayan/* source ~/.mutt/accounts/sanchayan
#folder-hook Victor/* source ~/.mutt/accounts/victor folder-hook nilenso/* source ~/.mutt/accounts/nilenso
set mail_check = 0 set mail_check = 0
set envelope_from set envelope_from
@ -73,7 +75,4 @@ macro index L "<enter-command>unset wait_key<enter><shell-escape>read -p 'notmuc
# 'a' shows all messages again (supersedes default <alias> binding) # 'a' shows all messages again (supersedes default <alias> binding)
macro index a "<limit>all\n" "show all messages (undo limit)" macro index a "<limit>all\n" "show all messages (undo limit)"
set header_cache=~/Gmail/mutt_cache/ # a much faster opening of mailboxes... # macro index D "<save-message>+/Trash<enter>" "Move message to the trash"
macro index D "<save-message>+/Trash<enter>" "Move message to the trash"

View file

@ -11,7 +11,7 @@
# configured here named ".notmuch". # configured here named ".notmuch".
# #
[database] [database]
path=/home/core/Mail path=/home/core/Gmail
# User configuration # User configuration
# #
@ -30,8 +30,8 @@ path=/home/core/Mail
# #
[user] [user]
name=Sanchayan Maity name=Sanchayan Maity
primary_email=maitysanchayan@gmail.com primary_email=sanchayan@nilenso.systems
other_email=victorascroft@gmail.com; other_email=maitysanchayan@gmail.com;
# Configuration for "notmuch new" # Configuration for "notmuch new"
# #