Support #475
Updated by Daniel Curtis about 10 years ago
Getmail is a useful tool for fetching mail from a remote mail server and delivering them to local mail account. This is useful for keeping emails concurrent between different mail servers if used as a cron job.
Install Getmail
* Update ports tree:
<pre>
portsnap fetch extract
</pre>
* Install Getmail:
<pre>
cd /usr/ports/mail/getmail
make install clean
</pre>
* Prepare getmail environment:
<pre>
cd
mkdir .getmail
cp /usr/local/share/examples/getmail/getmailrc-examples .getmail/getmailrc
</pre>
* Edit the .getmail/getmailrc file to suit your remote servers information.
h3. Retrieving emails from multiple accounts
* Create a separate getmail rc file for each account, and run getmail with multiple --rcfile options.
<pre>
cd ~/.getmail
mkdir getmail.d
</pre>
* Create first user
vi ~/.getmail/getmail.d/john.getmailrc
<pre>
#* And and the following:
</pre>
<pre>
## john@example.com
[options]
verbose = 0
read_all = false
delete = false
[retriever]
type = SimplePOP3Retriever
server = mail.example.com
username = john@altservice.com
password = Password
[destination]
type = MDA_external
path = /usr/local/libexec/dovecot/deliver
arguments = ("-e", "-f", "%(sender)", "-d", "john@altservice.com")
</pre>
* Create next user
<pre>
vi ~/.getmail/getmail.d/bob.getmailrc
</pre>
#* And add the following:
<pre>
## bob@example.com
[options]
verbose = 0
read_all = false
delete = false
[retriever]
type = SimplePOP3Retriever
server = mail.example.com
username = bob@altservice.com
password = Password
[destination]
type = MDA_external
path = /usr/local/libexec/dovecot/deliver
arguments = ("-e", "-f", "%(sender)", "-d", "bob@altservice.com")
</pre>
* Of course, it's really easy to script this for a large number of rc-* files. You might create a script in /usr/local/bin/run-getmail.sh containing:
<pre>
#!/bin/sh
set -e
cd /path/to/my-rc-directory
rcfiles=""
for file in rc-* ; do
rcfiles="$rcfiles --rcfile $file"
done
exec /usr/local/bin/getmail $rcfiles $@
</pre>