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

First install sendxmpp with apt-get install sendxmpp, then create the config file as /etc/sendxmpp.conf and insert XMPP credentials:

<sender>@<sender_server>:<port> <password>

Set the right permissions chmod 600 /etc/sendxmpp.conf and owner chown Debian-exim:Debian-exim /etc/sendxmpp.conf

Then create a script to call sendxmpp /usr/sbin/mail2xmpp. It might be that you could put this completely into the alias, however I decided to use the script. Exchange your receiving ID. -t enables the TLS connection for sending the message.

#!/bin/bash
echo "$(cat)" | sendxmpp -t -f /etc/sendxmpp.conf <receiver>@<receiving_server>

Make the script executable chmod 755 /usr/sbin/mail2xmpp and create the alias for the user, which E-Mails you want to forward in /etc/aliases:

# /etc/aliases
root:,|/usr/local/bin/mail2xmpp

To activate pipe forwarding we have to create /etc/exim4/exim4.conf.localmacros SoWhatIsTheSolution

SYSTEM_ALIASES_PIPE_TRANSPORT = address_pipe

After that run newaliases and service exim4 restart for config to take effect. Now you should be able to test if it works, by simply sending a local test E-Mail to user root.


Christian

Author

1 comment

Thank you for this blog post as it was very useful to me. I also set it up with slight changes and wrote it down in german on my blog: https://blog.mdosch.de/2017/09/11/system-mails-von-linux-ueber-xmpp-empfangen/


Please Note: By submitting your comment your browser will send the values of the form fields (and the typical browsing meta data) to the API of Staticman. If you don't want to connect to a third party, you should E-Mail me.