char/imapfilter-config
git clone https://git.t4t.associates/char/imapfilter-config
1e8dd98
main
1options . certificates =false 2options . create =true 3options . subscribe =true 4 5local accounts =dofile ( os . getenv ( 'HOME' ) .. '/.config/imapfilter/accounts.lua' ) 6 7for _ , credentials in ipairs ( accounts ) do 8local password =os . getenv ( credentials . password_env ) 9assert ( password and password ~= '' , 'Set ' .. credentials . password_env .. ' in /var/secrets/imapfilter.env first' ) 10 11local account =IMAP { 12server =credentials . server , 13port =993 , 14ssl ='auto' , 15username =credentials . username , 16password =password , 17} 18 19local inbox =account . INBOX 20local needs_attention =inbox : contain_subject ( 'suspicious activity' ) 21+ ( inbox : contain_subject ( 'password' ) * inbox : contain_subject ( 'reset' )) 22+ inbox : contain_subject ( 'verification code' ) 23 24local notifications =( inbox : contain_from ( 'noreply@wise.com' ) 25+ inbox : contain_from ( 'service@paypal.co.uk' ) 26+ inbox : contain_from ( 'noreply@steampowered.com' ) 27+ inbox : contain_from ( 'auto-confirm@info.thetrainline.com' ) 28+ inbox : contain_subject ( 'signed in' ) 29+ inbox : contain_subject ( 'new sign-in' ) 30+ inbox : contain_subject ( 'new sign in' ) 31+ inbox : contain_subject ( 'new login' ) 32+ inbox : contain_subject ( 'new device' )) - needs_attention 33 34( credentials . username .. ': ' .. # notifications .. ' messages match notification rules' ) 35assert ( notifications : move_messages ( account [ 'notifications' ]), 'Failed to move notifications for ' .. credentials . username ) 36 37local automated =( inbox : contain_field ( 'List-ID' , '' ) 38+ inbox : contain_field ( 'List-Unsubscribe' , '' ) 39+ inbox : contain_field ( 'Precedence' , '' ): match_field ( 'Precedence' , [[(?i)^[ \t]*(?:bulk|list|junk)\b]] ) 40+ inbox : contain_from ( 'no-reply@revolut.com' )) - needs_attention 41 42( credentials . username .. ': ' .. # automated .. ' messages match automated mail rules' ) 43assert ( automated : move_messages ( account [ 'automated mail' ]), 'Failed to move mail for ' .. credentials . username ) 44end