From: Christian Heller Date: Sun, 16 Dec 2018 00:19:38 +0000 (+0100) Subject: Add POP3 account fetching to mail server setup. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/do_day?a=commitdiff_plain;h=e8da7564122f157748e9a8f62e9066123d9d63ad;p=config Add POP3 account fetching to mail server setup. --- diff --git a/all_new_2018/linkable_etc_files/mail/etc/systemd/system/fetchmail.service b/all_new_2018/linkable_etc_files/mail/etc/systemd/system/fetchmail.service new file mode 100644 index 0000000..bd6792d --- /dev/null +++ b/all_new_2018/linkable_etc_files/mail/etc/systemd/system/fetchmail.service @@ -0,0 +1,7 @@ +[Unit] +Description=Run plom's fetchmail + +[Service] +Type=oneshot +User=plom +ExecStart=/bin/sh -c 'fetchmail' diff --git a/all_new_2018/linkable_etc_files/mail/etc/systemd/system/timers.target.wants/fetchmail.timer b/all_new_2018/linkable_etc_files/mail/etc/systemd/system/timers.target.wants/fetchmail.timer new file mode 100644 index 0000000..c67e8e7 --- /dev/null +++ b/all_new_2018/linkable_etc_files/mail/etc/systemd/system/timers.target.wants/fetchmail.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Run fetchmail once every minute + +[Timer] +OnCalendar=*-*-* *:*:00 + +[Install] +WantedBy=timers.target diff --git a/all_new_2018/setup_scripts/setup_mail.sh b/all_new_2018/setup_scripts/setup_mail.sh index c8d4254..7b256b7 100755 --- a/all_new_2018/setup_scripts/setup_mail.sh +++ b/all_new_2018/setup_scripts/setup_mail.sh @@ -64,6 +64,20 @@ echo "${mail_domain}" > /etc/mailname # allow for sophisticated stuff like dovecot-side sieve filtering (installed # with dovecot-sieve). apt install -y -o Dpkg::Options::=--force-confold postfix dovecot-imapd dovecot-lmtpd dovecot-sieve opendkim +cp "${config_tree_prefix}/user_files/dovecot.sieve" /home/plom/.dovecot.sieve +chown plom:plom /home/plom/.dovecot.sieve + +# In addition to our postfix server receiving mails, we funnel mails from a +# POP3 account into dovecot via fetchmail. It might make sense to adapt the +# ~/.dovecot.sieve to move mails targeted to the fetched mail account to their +# own mbox. +apt install -y fetchmail +cp "${config_tree_prefix}/user_files/fetchmailrc" /home/plom/.fetchmailrc +chown plom:plom /home/plom/.fetchmailrc +systemctl daemon-reload +systemctl start fetchmail.timer + +# Final advice to user. echo "TODO: Ensure MX entry for your system in your DNS configuration." echo "TODO: Ensure a proper SPF entry for this system in your DNS configuration; something like 'v=spf1 mx -all' mapped to your host." if [ "${add_dkim_record}" -eq "1" ]; then @@ -71,3 +85,4 @@ if [ "${add_dkim_record}" -eq "1" ]; then cat "${dkim_selector}.txt" fi echo "TODO: passwd plom" +echo "TODO: adapt /home/plom/.dovecot.sieve and /home/plom/.fetchmailrc" diff --git a/all_new_2018/user_files/dovecot.sieve b/all_new_2018/user_files/dovecot.sieve new file mode 100644 index 0000000..5346309 --- /dev/null +++ b/all_new_2018/user_files/dovecot.sieve @@ -0,0 +1,8 @@ +require ["fileinto"]; +require ["mailbox"]; +if address :is "from" "foo@bar.com" { + fileinto :create "foo"; +} +if address :is :domain "to" "example.com" { + fileinto :create "example.com"; +} diff --git a/all_new_2018/user_files/fetchmailrc b/all_new_2018/user_files/fetchmailrc new file mode 100644 index 0000000..b437563 --- /dev/null +++ b/all_new_2018/user_files/fetchmailrc @@ -0,0 +1,2 @@ +# remove "keep" if you're sure about your setup; it keeps mails on server from getting deleted +poll mail.example.com protocol pop3 username "foo@example.com" password "PASSWORD" ssl keep