Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This 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!


  Search this Thread
Old 05-06-2013, 09:13 AM   #1
LQ Newbie
Registered: May 2013
Posts: 2

Rep: Reputation: Disabled
ssmtp sends as email attachment instead of body text


I would really appreciate any help with this as I'm thoroughly stuck.

I've set up rkhunter to run as a cron job and then email any warnings etc using ssmtp via gmail with this script:

/usr/local/bin/rkhunter --versioncheck
/usr/local/bin/rkhunter --update
/usr/local/bin/rkhunter --cronjob --report-warnings-only
) | /bin/mail -v -s 'rkhunter daily run'
It all works ok, except that it sends the output as an attachment rather in the body.

It happens whether it is run via cron or within a normal shell.

I found a similar problem relating to encoding and tried piping it like this
[rkhunter outpu] | iconv -c -t UTF-8 | /bin/mail -v -s 'rkhunter daily run'
but that didn't fix it either

/etc/environment has locale set to en_US

I tried setting locale within the scrip like this :
export LC_ALL=$LOC
This sends text as the body in an email like you would expect:

echo 'some text' | /bin/mail -v -s 'UTF Test'
and displays :
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

while the output from rkhunter shows this when sent:
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Old 05-06-2013, 10:26 AM   #2
LQ Newbie
Registered: May 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
Ok, a little unstuck now. Putting this up if it helps anyone else. I'm not sure if this is the right way to solve this but it works for now.

Changing the script to this works now
# send rkhunter output to a file
rkhunter --cronjob --report-warnings-only > /var/log/rkhuntercron.log

# Overwrite old sendthis.txt with file containing TO/FROM/SUBJECT info contained in mailtome.txt that ssmtp expects
cat /etc/cron.daily/mailtome.txt > /etc/cron.daily/sendthis.txt

# Append rkhunter output to sendthis.txt
cat /var/log/rkhuntercron.log >> /etc/cron.daily/sendthis.txt

# Send it with ssmtp
/usr/sbin/ssmtp < /etc/cron.daily/sendthis.txt
In this case mailtome.txt should look like this :
From: root@myhost
Subject: rkhunter daily cron
However the following still sends it as an attachment! Arrggh! Why?

cat /var/log/rkhuntercron.log | mail -v -s 'rkhunter mail test'
[<-] 220 ESMTP xxxxxxxxxxxxx.xx - gsmtp
[->] EHLO
[<-] 220 2.0.0 Ready to start TLS
[->] EHLO
[<-] 334 xxxxxxxxxxx
[->] xxxxxxxxxxxxxxxx
[<-] 334 xxxxxxxxxxx
[<-] 235 2.7.0 Accepted
[->] MAIL FROM:<>
[<-] 250 2.1.0 OK - gsmtp
[->] RCPT TO:<>
[<-] 250 2.1.5 OK xxxxxxxxxxxxx.xx - gsmtp
[->] DATA
[<-] 354  Go ahead xxxxxxxxxx.xx - gsmtp
[->] Received: by (sSMTP sendmail emulation); Mon,  6 May 2013 17:54:33 +0400
[->] From: "root" <>
[->] Date: Mon, 06 May 2013 17:54:33 +0400
[->] To:
[->] Subject: rkhunter mail test
[->] User-Agent: Heirloom mailx 12.4 7/29/08
[->] MIME-Version: 1.0
[->] Content-Type: application/octet-stream
[->] Content-Transfer-Encoding: base64


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
mail sends a .dat file instead of text in body j-me Linux - Server 7 03-06-2013 04:17 AM
how ssmtp email client can receive email delivery golden_boy615 Linux - General 0 05-08-2011 02:14 AM
convert email files with attachment to save as attachment file (metamail?) ted_chou12 Linux - Software 2 04-08-2011 09:01 PM
How to configure an email server that sends email to hotmail with Fedora? acarri Linux - Server 5 03-10-2010 03:05 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:18 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration