Hello there,
Yunohost is a great piece of software, and today I would like to share my experience on how to make fetchmail work with yunohost.
fetchmail is a useful program that retrieves emails from external servers (pop3 or imap)
Unfortunately if you follow the official man page you’ll only get errors, basically because fetchmail service and daemon are launched by a fetchmail user, that has absolutely no right to use dovecot’s services. Adding user fetchmail in mail group does not solve the problem. It seems that only 2 users have rights to use yunohost’s dovecot : root and vmail
So after having imagined and tested several solutions, I will share with you the one I found that absolutely works, and doesn’t jeopardize yunohost config files.
The main idea is to get fetchmail launched by vmail user (who is entitled by yunohost to manage dovecot mda)
first setup fetchmail
sudo apt-get install fetchmail
then create your config file /home/vmail/fechcmdvmail
sudo -u vmail nano /home/vmail/fechcmdvmail
here’s an example which you’ll have to customize to suit your needs
- your yunohost user is usernameonyunohost
- your external email is emailaddress@external-domain.com
- you retreive email over pop3 protocol on pop.external-domain.com
- be careful : the nokeep parameter will erase messages from emailaddeess@external-domain.com inbox
- you may retrieve several mailboxes from several servers, just add others poll statements
other examples
http://www.fetchmail.info/fetchmail-man.html
https://www.howtoforge.com/debian_etch_fetchmail
DO NOT FORGET the mda parameter, else you’ll destroy your local mailbox!!!
#/home/vmail/fechcmdvmail
set syslog
set postmaster root
poll pop.external-domain.com proto pop3 user "emailaddress@external-domain.com" password "your-email-password" is "usernameonyunohost" here
mda "/usr/lib/dovecot/deliver -d %T" nokeep
Important : chmod
sudo -u vmail chmod 0600 /home/vmail/fetchcmd
in order to test this config file
killall fetchmail sudo -u vmail fetchmail --daemon 0 -v -f /home/vmail/fechcmdvmail
Normally you should receive emails left on emailaddeess@external-domain.com on your usernameonyunohost mailbox
last step : setup a daemon which will get launched by a cron at boot time, and fetch mails every 1800 seconds
sudo -u vmail crontab -e
use nano when prompted
and add the following line
@reboot fetchmail --daemon 1800 -v -f /home/vmail/fetchcmdvmail
ctrl-X to save
then reboot, and enjoy!
you may verify that the cron is actually running
ps aux |grep fetchmail
If you have problems, don’t forget to watch the logs:
grep CRON /var/log/syslog
grep fetchmail /var/log/syslog
tail -n 200 /var/log/mail.log