Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

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
1  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.