My setup includes a script that send a mail to a local user via the exim command line. This script is called as root (Reality is of course more complicated, but this seems to be a minimal working example).
/home/jens/send_mail: #!/bin/sh cat /home/jens/testmail | /usr/bin/exim -bm jens
Running this script from a root shell works fine. The mail is delivered without problems.
Now I try to automate this script and call it from a systemd service:
/etc/systemd/system/send_mail.service: [Unit] Description=Send mail to jens [Service] Type=oneshot ExecStart=/home/jens/send_mail [Install] WantedBy=multi-user.target
systemctl start send_mail.service does not deliver the mail, but places it in the exim queue to be delivered later. In my real setup, I find lines reading
... exim: 2020-07-16 23:09:40 1jwB8O-0019n4-Lj failed to write to main log: length=91 result=-1 errno=9 (Bad file descriptor) ... exim: write failed on panic log: length=116 result=-1 errno=9 (Bad file descriptor)
in my journal. To my knowledge, I have no exim-specific environment variables for my root shell. What could be the cause of this different behavior?
I am using exim 4.94 on Arch Linux. Please ask if you need further details.