# fetches mails for me { lib, pkgs, config, ... }: { users.users.mailUser = { isNormalUser = true; description = "collects mails for me"; hashedPassword = "!"; name = "mailfetcher"; openssh.authorizedKeys.keyFiles = config.users.users.root.openssh.authorizedKeys.keyFiles; }; # configure passwords krops.userKeys = { "gmail.palipalo9" = { user = config.users.users.mailUser.name; source = toString ; requiredBy = ["fetchmail.service"]; }; "gmx.palo_van_dalo" = { user = config.users.users.mailUser.name; source = toString ; requiredBy = ["fetchmail.service"]; }; "gmx.ingolf_wagner" = { user = config.users.users.mailUser.name; source = toString ; requiredBy = ["fetchmail.service"]; }; "web.pali_palo" = { user = config.users.users.mailUser.name; source = toString ; requiredBy = ["fetchmail.service"]; }; "siteground.contact" = { user = config.users.users.mailUser.name; source = toString ; requiredBy = ["fetchmail.service"]; }; }; environment.systemPackages = [ pkgs.muchsync ]; # configure accounts home-manager.users.mailUser.accounts.email = { accounts = { palo_van_dalo-gmx = { primary = false; address = "palo_van_dalo@gmx.de"; aliases = [ ]; realName = "Ingolf Wagner"; userName = "palo_van_dalo@gmx.de"; passwordCommand = "cat ${toString config.krops.userKeys."gmx.palo_van_dalo".target}"; imap = { host = "imap.gmx.net"; port = 993; }; mbsync = { enable = true; create = "both"; }; notmuch.enable = true; }; ingolf-wagner-gmx = { primary = false; address = "ingolf.wagner@gmx.de"; aliases = [ ]; realName = "Ingolf Wagner"; userName = "ingolf.wagner@gmx.de"; passwordCommand = "cat ${toString config.krops.userKeys."gmx.ingolf_wagner".target}"; imap = { host = "imap.gmx.net"; port = 993; }; mbsync = { enable = true; create = "both"; }; notmuch.enable = true; }; pali_palo = { primary = false; address = "pali_palo@web.de"; aliases = [ ]; realName = "Ingolf Wagner"; userName = "pali_palo@web.de"; passwordCommand = "cat ${toString config.krops.userKeys."web.pali_palo".target}"; imap = { host = "imap.web.de"; port = 993; }; mbsync = { enable = true; create = "both"; }; notmuch.enable = true; }; gmail = { # for google accounts you have to allow 'less secure apps' in accounts.google.com primary = true; address = "palipalo9@googlemail.com"; aliases = [ ]; realName = "Ingolf Wagner"; userName = "palipalo9@googlemail.com"; passwordCommand = "cat ${toString config.krops.userKeys."gmail.palipalo9".target}"; imap = { host = "imap.gmail.com"; port = 993; }; mbsync = { enable = true; create = "both"; }; notmuch.enable = true; }; ingolf-wagner = { primary = false; address = "contact@ingolf-wagner.de"; aliases = [ ]; realName = "Ingolf Wagner"; userName = "contact@ingolf-wagner.de"; passwordCommand = "cat ${toString config.krops.userKeys."siteground.contact".target}"; imap = { host = "securees5.sgcpanel.com"; port = 143; tls.useStartTls = true; }; mbsync = { enable = true; create = "both"; }; notmuch.enable = true; }; }; }; # configure mbsync home-manager.users.mailUser.programs.mbsync.enable = true; systemd.services.fetchmail = { enable = true; serviceConfig = { User = config.users.users.mailUser.name; }; environment.NOTMUCH_CONFIG = "${config.users.users.mailUser.home}/.config/notmuch/notmuchrc"; script = '' echo "run mbsync" ${pkgs.isync}/bin/mbsync \ --verbose \ --all echo "run notmuch" ${pkgs.notmuch}/bin/notmuch new echo "run afew" ${pkgs.afew}/bin/afew --new --tag -v ''; }; systemd.timers.fetchmail = { enable = true; # timerConfig.OnCalendar = " *-*-* *:00:00"; timerConfig.OnCalendar = "*:0/10"; wantedBy = ["multi-user.target"]; }; # configure notmuch home-manager.users.mailUser.programs.notmuch = { enable = true; new.tags = [ "unread" "inbox" "new" ]; }; home-manager.users.mailUser.home.file."notmuch" = { source = "${config.users.users.mailUser.home}/.config/notmuch/notmuchrc"; target = ".notmuch-config"; }; # a few config home-manager.users.mailUser.programs.afew = { enable = true; extraConfig = with lib; let template = index: { tags, query, message ? "generic", ... }: '' [Filter.${toString index}] query = ${query} tags = ${concatStringsSep ";" tags} message = ${message} ''; filters = [ {query = "from:no-reply@backtrace.io"; tags = ["+sononym" "-inbox" "-unread"];} {query = "from:linkedin.com"; tags = [ "+linked" "+jobs" "-inbox" ];} {query = "from:computerfutures.com OR from:computerfutures.de"; tags = [ "+jobs" "-inbox" ];} {query = "from:xing.com"; tags = [ "+jobs" "-inbox" ];} {query = "from:ebay.com OR from:ebay.de OR from:ebay.net"; tags = [ "+ebay" "+shop" "+billing"];} {query = "from:seek.com.au"; tags = [ "+jobs" "-inbox" ];} {query = "from:bahn.de"; tags = [ "+billing" "+bahn" ];} {query = "from:fysitech.atlassian.net OR to:engiadina-pwa@noreply.github.com"; tags = [ "+mia" "+work" "-unread" "-inbox"];} {query = "from:circleci.com OR (from:noreply@github.com AND to:audio-overlay@googlegroups.com)"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:getdigital.de"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:digitalo.de"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:puppet.com"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:mixcloudmail.com AND subject:Weekly Update"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:facebook.com OR from:facebookmail.com"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:getpocket.com"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:oknotify2.com"; tags = [ "+okcupid" ];} {query = "from:oknotify2.com AND NOT subject:New message"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:paulaschoice.com"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:samplemagic.com OR from:wavealchemy.co.uk OR from:creators.gumroad.com"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:immobilienscout24.de"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:magix.net"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:booking.com"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:hackster.io"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:trade4less.de"; tags = [ "-inbox" "-unread" "+junk" ];} {query = "from:taxback.de OR to:taxback.de"; tags = ["+steuer"] ;} {query = "from:campact.de"; tags = ["+campact" "+politics"] ;} {query = "from:menospese.com"; tags = ["+junk" "-unread" "-inbox"] ;} {query = "from:aliexpress.com"; tags = ["+shop" "+aliexpress"] ;} {query = "from:congstar.de"; tags = ["+billing" "+congstar" "-inbox" "-unread"] ;} {query = "from:congstarnews.de"; tags = ["+congstar" "-inbox" "-unread" "+junk"] ;} {query = "from:fitnessfirst.de"; tags = ["-inbox" "-unread" "+junk"] ;} {query = "from:steampowered.com AND NOT ( subject:purchase OR subject:received )"; tags = ["-inbox" "-unread" ] ;} {query = "from:steampowered.com AND ( subject:purchase OR subject:received )"; tags = ["+billing" "+steam" ] ;} {query = "from:gog.com AND NOT subject:Bestellung"; tags = ["-inbox" "-unread" ] ;} {query = "from:gog.com AND subject:Bestellung"; tags = ["+billing" "+gog" ] ;} {query = "from:drive-now.com"; tags = ["+billing" "+drivenow" "-inbox" "-unread"] ;} {query = "from:mindfactory.de"; tags = ["+shop" "+billing"] ;} {query = "from:zalando.de"; tags = ["+shop" "+billing" "+zalando"] ;} {query = "from:ing.de"; tags = ["+bank" "+ingdiba"] ;} {query = "from:nab.com.au"; tags = ["+bank" "+nab" "-inbox" "-unread"] ;} {query = "from:dkb.de"; tags = ["+bank" "+dkb"] ;} {query = "from:o2online.de"; tags = ["+billing" "+o2"] ;} {query = "from:betfair.com"; tags = ["+work" "+betfair"] ;} {query = "from:ghostinspector.com"; tags = ["-unread" "-inbox" "+junk"] ;} {query = "from:travis-ci.org AND subject:csv-to-qif"; tags = ["+development" "+csv-to-qif"] ;} {query = "to:proaudio@lists.tuxfamily.org"; tags = ["-inbox" "-unread"] ;} {query = "tag:lists AND from:nixos1@discoursemail.com"; tags = ["+nixos" "+discourse"] ;} {query = "from:limebike.com AND (subject:Funds OR subject:Receipt)" ; tags = ["-inbox" "-unread" "+billing" "+limebike"] ;} {query = "from:hetzner.com OR from:hetzner.de" ; tags = ["+hetzner"] ;} {query = "from:freemusicarchive.org" ; tags = ["+FMA"] ;} {query = "from:namecheap.com" ; tags = ["+namecheap" "+billing"] ;} {query = "from:nintendo.com" ; tags = ["+nintendo" "+billing"] ;} {query = "from:oculus.com AND subject:receipt" ; tags = ["+oculus" "+billing"] ;} {query = "from:vstbuzz.com" ; tags = ["+junk" "-inbox" ] ;} {query = "from:runtastic.com" ; tags = ["+junk" "-inbox" ] ;} {query = "from:letterboxd.com" ; tags = ["+junk" "-inbox" ] ;} {query = "from::microsoftstoreemail.com" ; tags = ["+junk" "-inbox" ] ;} {query = "from:car2go.com" ; tags = ["-inbox" "-unread" ] ;} {query = "from:sixt.de" ; tags = ["-inbox" "-unread" ] ;} {query = "from:meetup.com" ; tags = ["-inbox" "-unread" "+meetup"] ;} {query = "from:slack.com" ; tags = ["+slack"] ;} {query = "from:keybase.io" ; tags = ["+keybase"] ;} {query = "from:tumblr.com" ; tags = ["+junk" "-inbox" "-unread"];} {query = "from:jobs2web.com" ; tags = ["+newzealand" "+jobs" "-inbox" ];} {query = "from:mailings.gmx.net" ; tags = ["+junk" "-inbox" "-unread"];} {query = "from:paypal.de AND subject:Bestätigung"; tags = ["-unread" "+paypal" "+billing"] ;} {query = "to:renoise@ingolf-wagner.de OR to:root@renoise.com OR from:renoise.com OR to:admin@renoise.com"; tags = ["+renoise"] ;} {query = "from:amazon.de OR from:amazon.com AND NOT to:renoise.com"; tags = ["+shop" "+amazon" "+billing"];} { query = "to:renoise.com AND NOT ( from:renoise.com OR from:root OR from:hetzner.com OR from:hetzner.de OR from:amazon.com OR from:gmail.com )"; tags = [ "-inbox" "-unread" "+junk" "+renoise" ]; } # final rules to make imap sync stuff easier # there can only be one output folder tag, and theses rules are prioritized { query = "tag:fraud" ; tags = ["-inbox" "-archive" "-junk" "-unread" ]; message = "clean up tag fraud";} { query = "tag:junk" ; tags = ["-inbox" "-archive" "-fraud" "-unread" ]; message = "clean up tag junk";} { query = "tag:archive" ; tags = ["-inbox" "-junk" "-fraud" "-unread" ]; message = "clean up tag archive";} { query = "tag:inbox" ; tags = ["-archive" "-junk" "-fraud"]; message = "clean up inbox";} { query = "tag:killed"; tags = ["-inbox" "-unread"]; message = "clean up tag killed" ;} # remove new tag at the end { query = "tag:new"; tags = ["-new"]; message = "remove new tag at the end" ;} ]; in '' # Tag mails which are mailing lists [ListMailsFilter] # Tag mails as killed if the thread has been marked as "killed" [KillThreadsFilter] ${concatStringsSep "\n" (imap0 template filters)} ''; }; }