0
I am using esmtp to send email as an output of cron job. The SMTP server and credentials configuration are stored under my $HOME/.esmtprc. However it looks like the $HOME env variable is set to '/', rather than to HOME from /etc/passwd as the manual suggests. I changed /usr/sbin/sendmail to output environment variables to file and I see this:
HOME='/'
However the email headers contain this:
X-Cron-Env: <HOME=/home/username>
which is correct. So why is $HOME unset for the esmtp?
Unless somebody already answered your question, it's better not to append edits all the time, but rather re-write the question so it is as clear as possible. – slhck – 2011-07-27T10:01:10.320
Do you use
sudo
or something else that resets your environment? Have you considered usingenv
to set the home directory explicitly for thesendmail
process? – Daniel Beck – 2011-07-27T11:11:07.930@Daniel: no sudo. How should I use env to do that? Even if that is needed, why is it not documented? – mehturt – 2011-07-27T11:20:31.343
Thinking about this once again, it looks like the HOME is set for the script run from crontab, but unset for sendmail which is sending the output of the cron jobs. So I guess I need to set up the SMTP configuration to /etc/esmtprc and have it readable by the user(s) that is running cron jobs. – mehturt – 2011-07-27T11:25:10.827