OpenLDAP schema to dynamically generate a configuration file to poll mails via fetchmail
.
fetchmailEnabled
>>TRUE
orFALSE
- used to deteced if the entry should be parsed or notfetchmailServer
>> DNS-Name of the Mailserver (but also works with IP-Addresses)fetchmailProtocol
>> e.g.pop3
,imap
or any other protocol supported by fetchmailfetchmailUsername
>> Username of the mailbox you're connecting tofetchmailPassword
>> same as abovefetchmailCustom
>> add any additionial commands likenokeep fetchall
fetchmailSSL
>>TRUE
orFALSE
- set this to enable SSL support
Basically you should have two Trees:
- one with the global settings used for each individual user, like
fetchmailServer
,fetchmailProtocol
andfetchmailCustom
- another tree with the actual users (should be
inetOrgPerson
). These must have at least addedfetchmail
toObjectClass
and a validmail
attribute. Usually you also add the attributesfetchmailUsername
andfetchmailPassword
So the tree looks like:
dc=foo,dc=bar
|_ ou=Templates
| |_ cn=fetchmailDefaults
| |_ fetchmailEnabled = true
| |_ fetchmailServer = pop.myserver.com
| |_ fetchmailProtocol = pop3
| |_ fetchmailCustom = nokeep fetchall
| |_ fetchmailSSL = false
| |_ sn = Fetchmail Default Values
| |_ objectClass = top, inetOrgPerson, fetchmail
|_ ou=Users
|_ uid=testuser
|_ mail = [email protected]
|_ fetchmailEnabled = true
|_ fetchmailUsername = testuser
|_ fetchmailPassword = topSecret
|_ fetchmailSSL = true <-- This would overwrite the Default-Settings
This will generate the following line that will be passed to fetchmail:
poll pop.myserver.com proto pop3 user testuser pass toSecret is [email protected] here nokeep fetchall ssl
add this line to /etc/ldap/slapd.conf
:
include /etc/ldap/schema/fetchmail.schema
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/fetchmail.ldif
Change
BASE_DN
BASE_DEFAULTS
BASE_USERS
that it fits your LDAP configuration.
Run fetchmail.sh
and take a look at the output - it should be similiar to the poll ...
line.
If everything is fine setup a Cronjob to invoke the script:
*/5 * * * * /usr/local/bin/fetchmail.sh | fetchmail -f -