This is useful if you either lack a complete e-mail infrastructure for your server, or if you don't need a full-fledged e-mail server setup with domain names and all that.
I personally use it to get the information as fast as possible, rather than wait for the next polling of my e-mail client on my cellphone.
First we install sendxmpp. This is a command-line client to send messages to XMPP-accounts or chatrooms.
apt-get install sendxmpp
It's possible to pass parameters like username and possword directly to sendxmpp, but that would reveal the password to other users if they view the processlist. So to prevent it, we make the file
/etc/sendxmpprc for sendxmpp with the following content:
Then we adjust the ownership of it:
chmod 600 /etc/sendxmpprc chown nobody:nogroup /etc/sendxmpprc
To make the server's mail transfer agent, in this case "postfix", we edit
/etc/aliases and add the following, adjusted to your needs:
root: "|sendxmpp -f /etc/sendxmpprc firstname.lastname@example.org"
... or if you also want an e-mail to be sent to email@example.com:
root: "|sendxmpp -f /etc/sendxmpprc firstname.lastname@example.org",localuser,email@example.com
... or if you want to use encryption:
root: "|sendxmpp --tls --tls-ca-path /etc/ssl/certs -f /etc/sendxmpprc firstname.lastname@example.org",localuser,email@example.com
Then make postfix re-read the changes
Send a test-message with sendxmpp
su -s /bin/bash nobody echo test | sendxmpp -f /etc/sendxmpprc exit
Send a test-message with mail, which will pipe to sendxmpp:
echo test | mail -s test firstname.lastname@example.org
Here's an example of how it looks when receiving an e-mail about unattended upgrades via XMPP on SailfishOS: