problems with calling mail from a cron job

I wrote a simple program that sends warning emails to certain people. It simply calls mail to do the trick.
Everything works fine when I execute my program manually. However, when I use cron to call it every day automatically, things go wrong. mail returns error code 1 and prints
“/root/dead.letter” 80/7781
or something similar. My letter ends up in the dead.letter file.
To make things more complicated, there is one person who gets his email, although all messages are routed through the same SMTP server (it’s configured with YaST). All the recipients are my collegues and our mailboxes are on the same server, so I don’t know what can be the difference.
Do you have an idea what can be the problem?

You should look at the output from the cron which would have the error messages from mailx (mail is a link to this). You should also look at the errors in /var/log/mail for clues. You may need to set some mailx settings in ~/.mailrc. Remember that in a cron job some environment variables are not at the values you would normally expect in an interactive shell. Notably $PATH.

Ok, it’s solved. Thanks for your help! It was really an environment issue. UTF-8 characters turned up in the messages, and I had to add LC_CTYPE=en_US.UTF-8 to the mail process’ environment to work from cron.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

That’s an interesting fix. I apparently don’t do much Unicode in my
e-mails but this is good to know in case I ever do. Thanks for posting
back your results.

Good luck.

szobid wrote:
> Ok, it’s solved. Thanks for your help! It was really an environment
> issue. UTF-8 characters turned up in the messages, and I had to add
> LC_CTYPE=en_US.UTF-8 to the mail process’ environment to work from cron.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJdwxY3s42bA80+9kRAot5AJ0XBsNa8coeDo02BeKdL1j0//cuXgCfc32P
sOGOziA9GB76z6Y8ouV0kw4=
=Ceuo
-----END PGP SIGNATURE-----