Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


However the email headers contain this:

X-Cron-Env: <HOME=/home/username>

which is correct. So why is $HOME unset for the esmtp?

share|improve this question
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 Jul 27 '11 at 10:01
Thanks, I'll do that – mehturt Jul 27 '11 at 10:06
Do you use sudo or something else that resets your environment? Have you considered using env to set the home directory explicitly for the sendmail process? – Daniel Beck Jul 27 '11 at 11:11
@Daniel: no sudo. How should I use env to do that? Even if that is needed, why is it not documented? – mehturt Jul 27 '11 at 11:20
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 Jul 27 '11 at 11:25

You must log in to answer this question.

Browse other questions tagged .