Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am running a Cron job which mails the content of a log report every day. The problem is that the contents are sent as an attachment instead of as the body of the email. The strange thing is that if I run the instructions from the command line everything works fine, but if I do so from the Cron job the log report is attached instead of being sent inline.
The instruction I use is:
Code:
mail -s "logfile for cron" cron@example.com </var/log/cron-log
Following some advice I read on a blog I also tried this instruction in my Cron file, but the result is the same: it works fine from the command line, but attaches the report when run from Cron:
Code:
echo "Content-Type: text/plain;" | mail -s "logfile for cron" cron@example.com </var/log/cron-log
Does anybody know how to ensure the content of the log file is inline?
Hi Berhanie,
I tried what you said and found that the mail program was "/bin/mail" and used this path in my Cron script. The result is however the same: the log report comes as an attachment.
/bin/mail, so far as i am aware, isn't capable of MIME, and so cannot send attachments by itself. maybe you can examine the headers of the two mails (commandline- and cron-generated) for clues. it may be that you're not sending the exact email both times, or that you're using two different mail clients to read them.
* When the text of an outgoing message contains illegal byte sequences
in non-interactive mode, do not refuse sending it but send it with
the "application/octet-stream" content type instead...
That explains how an inline message can get converted to an attachment. Now, you might
examine either the file you're sending or your crontab script for the origin of non-ascii
characters.
Excellent, you've hit it right on the head: the problem was that I was including the Euro symbol in the report. I guess removing this should solve the problem. I will be reporting back.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.