Your ultimate problem was that mailx, when called from a shell script run by smartd, started by systemd, on Arch Linux, was not reading the root user's $HOME/.mailrc file.
This was caused by a few factors:
- The
mailxon Arch Linux, s-nail, relies on the environment variableHOMEwhen looking for the.mailrcfile. IfHOMEisn't present, it uses the current working directory.
if ((cp = getenv("HOME")) == NULL)
cp = "."; /* XXX User and Login objects; Login: pw->pw_dir */
homedir = savestr(cp);
systemdsets HOMEHOMEonly when the unit configuration file contains theUseroption.
From Environment variables in spawned processes:
$USER, $LOGNAME, $HOME, $SHELL
User name (twice), home directory, and the login shell. The variables are set for the units that have User= set, which includes user systemd instances.
Since there was no HOME variable in the environment provided to smartd, and it was likely started in the / directory, mailx couldn't find adidn't read the $HOME/root/.mailrc to readfile.
WorkaroundTo fix: add the line
export HOME=~
or
export MAILRC=~/.mailrc
to the shell script before it invokes mailx
or (untestednot tested by me) add
User=root
to the [Service] stanza of your smartd.service unit configuration file.