emailing log files as body text

In an attempt to make the eggdrop logs searchable, I wrote a script (backuplogs.sh) which would send a copy of the logs by email so they could be searched from there.

I tried two methods, both of which had issues:
  • (uuencode $filename $filename) | mail -s $subject $mailto
  • mail -s "$subject" $mailto < "$file"

The issue are as follows:
  • Email clients are unable to search contents of attachments
  • The log file will not render as body text as the mail command attempts to parse the file for headers.

Possible solutions:
  • Encode the body (not as an attachment)
  • Escape the body so the text will not be rendered by the mail command

Unfortunately I've not worked out how to do this.

Any ideas?
 
If it's plain text don't uuencode it. You can just add it.

Code:
% cat some_text | mailx -s 'my subject' me@example.com
 
Pushrod said:
So how does one send a file as an attachment?

Just uuencoding it should normally work. If you want a 'real' MIME attachment you'll have to use something like mail/mutt:
[cmd=]mutt -a somefile.jpg -s 'my subject' me@example.com < body.txt[/cmd]
 
hm2k if your logs are managed by syslogd, you can pipe it to mail(1) from syslogd.conf when they rotating for example
 
Back
Top