To have a more comfortable way of receiving messages by my servers, I wanted all my root E-Mails to be forwarded to my mobile via XMPP. I only have a limited exim4 on my machine running, configured for local mail delivery only.
So what is the solution
1. Install sendxmpp
apt-get install sendxmpp
2. Create config file as “/etc/sendxmpp.conf”
as an example:
firstname.lastname@example.org supersecretpassword! mydomain.com
3. Set the right permissions and owner
chmod 600 /etc/sendxmpp.conf chown Debian-exim:Debian-exim /etc/sendxmpp.conf
4. Create a script to call sendxmpp as “/usr/sbin/mail2xmpp”. It might be that you could put this completely into the alias, however I decided to use the script.
Exchange with your receiving ID. “-t” enables the TLS connection for sending the message.
#!/bin/bash echo "$(cat)" | sendxmpp -t -f /etc/sendxmpp.conf
5. Make script executable
chmod 755 /usr/sbin/mail2xmpp
6. Create the alias for the user, which E-Mails you want to forward in “/etc/aliases”
root: , |/usr/sbin/mail2xmpp
7. To activate pipe forwarding we have to create “/etc/exim4/exim4.conf.localmacros”
SYSTEM_ALIASES_PIPE_TRANSPORT = address_pipe
8. Run newaliases and restart exim4 for config to take effect
newaliases service exim4 restart
Now you should be able to test if it works, by simply sending a local test E-Mail to user “root”.