0

I have use mutt to send mails. It works fine when I use my own user account: e.g. echo "foo bar" | mutt mymail@mymail.com

However, when I put the above command in /etc/lightdm/lightdm.conf (I want to receive the mail every time my PC is started), the command will be executed with root account, but the mails I receive has no contents in the email body (no "foo bar" is shown in the mail). How can I echo the contents in mutt when I use root account?

  • Could you include what you've got in your conf? This is likely just a syntax issue. – Oli May 22 '14 at 9:44
0

First of all, have you checked your root's mutt configuration is working? You're getting some emails so it probably is fine but humour me with:

echo "foo bar" | sudo mutt mymail@mymail.com

If that's all okay, then it's probably just a syntax issue in the script. When piping things you have to be careful that it's not being interpreted by something else. The easiest way to do this is to wrap the command inside another shell instance:

sh -c 'echo "foo bar" | mutt mymail@mymail.com'

That should ensure the pipe stays with the mutt.

  • Thank you for your reply! I checked the above two command. It works fine when I open a terminal to run them. But when I put the same script in lightdm.conf, so that every time the machine is started the scripts can be executed, but then I still receive mails with no contents in the body. Is it because when lightdm is started, it will not read some system configurations? – Starry May 22 '14 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.