qubes-doc/external/configuration-guides/fetchmail.md

108 lines
2.9 KiB
Markdown
Raw Normal View History

2014-10-06 10:02:15 -04:00
---
2015-04-10 16:17:45 -04:00
layout: doc
2014-10-06 10:02:15 -04:00
title: Fetchmail
permalink: /doc/fetchmail/
redirect_from:
- /en/doc/fetchmail/
- /doc/Fetchmail/
- /wiki/Fetchmail/
2014-10-06 10:02:15 -04:00
---
Fetchmail
=========
Fetchmail is standalone MRA (Mail Retrieval Agent) aka "IMAP/POP3 client". Its sole purpose is to fetch your messages and store it locally or feed to local MTA (Message Transfer Agent). It cannot "read" messages — for that, use a MUA like Thunderbird or [Mutt](/doc/mutt/).
2014-10-06 10:02:15 -04:00
Installation
------------
2018-02-04 10:20:42 -05:00
`dnf install fetchmail`
2014-10-06 10:02:15 -04:00
Configuration
-------------
Assuming you have more than one account (safe assumption these days), you need to spawn multiple fetchmail instances, one for each IMAP/POP3 server (though one instance can watch over several accounts on one server). The easiest way is to create template systemd unit and start it several times. Fedora does not supply any, so we have to write one anyway.
2017-04-27 11:21:11 -04:00
**NOTE:** this assumes you use [Postfix](/doc/postfix/) or Exim4 as your local MTA.
2014-10-06 10:02:15 -04:00
In TemplateVM create `/etc/systemd/system/fetchmail@.service`:
~~~
2014-10-06 10:02:15 -04:00
[Unit]
Description=Mail Retrieval Agent
After=network.target
Requires=postfix.service
[Service]
User=user
ExecStart=/bin/fetchmail -f /usr/local/etc/fetchmail/%I.rc -d 60 -i /usr/local/etc/fetchmail/.%I.fetchids --pidfile /usr/local/etc/fetchmail/.%I.pid
RestartSec=1
~~~
2014-10-06 10:02:15 -04:00
2017-04-27 11:21:11 -04:00
Alternatively, in Debian with Exim4:
~~~
[Unit]
Description=Mail Retrieval Agent
After=network.target
Requires=exim4.service
[Service]
User=user
ExecStart=/usr/bin/fetchmail -f /usr/local/etc/fetchmail/%I.rc -d 60 -i /usr/local/etc/fetchmail/.%I.fetchids --pidfile /usr/local/etc/fetchmail/.%I.pid
RestartSec=1
~~~
2014-10-06 10:02:15 -04:00
Then shutdown TemplateVM, start AppVM and create directory `/usr/local/etc/fetchmail`. In it, create one `.rc` file for each instance of fetchmail, ie. `personal1.rc` and `personal2.rc`. Sample configuration file:
~~~
2014-10-06 10:02:15 -04:00
set syslog
set no bouncemail
#set daemon 600
poll mailserver1.com proto imap
no dns
uidl
tracepolls
user woju pass supersecret
ssl
sslproto "TLS1"
sslcertfile "/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt"
sslcertck
mda "/usr/sbin/sendmail -i -f %F -- user"
fetchall
idle
# vim: ft=fetchmail
~~~
2014-10-06 10:02:15 -04:00
Then `chown -R user:user /usr/local/etc/fetchmail` and `chmod 600 /usr/local/etc/fetchmail/*.rc`. **This is important**, fetchmail will refuse to run with wrong permissions on its rc-file.
Next, add this to `/rw/config/rc.local`:
~~~
2014-10-06 10:02:15 -04:00
#!/bin/sh
for rc in /usr/local/etc/fetchmail/*.rc; do
instance=${rc%.*}
instance=${instance##*/}
2017-04-27 11:13:51 -04:00
systemctl --no-block start fetchmail@${instance}
2014-10-06 10:02:15 -04:00
done
~~~
2014-10-06 10:02:15 -04:00
Make sure the folder '/rw/config/qubes-bind-dirs.d' exists.
~~~
sudo mkdir -p /rw/config/qubes-bind-dirs.d
~~~
Create the file '/rw/config/qubes-bind-dirs.d/50_user.conf' with root rights.
Now edit it to append the '/var/spool/mail/' directory to the binds variable.
~~~
binds+=( '/var/spool/mail' )
~~~
2014-10-06 10:02:15 -04:00
Now reboot your AppVM and you are done.