LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem wirh mailx (https://www.linuxquestions.org/questions/linux-newbie-8/problem-wirh-mailx-920570/)

drazenmd 12-26-2011 10:26 AM

Problem wirh mailx
 
Hi,
I am trying to send mail from script. When I use this command evyrthing works great

echo "This is a test message" | mailx -s "Test" me@domain.net;

But if I put like this:

$f is name of file which I am reading
var=`cat $f`
echo "$var" | mailx -s "Test" me@domain.net;

it is sending email but without message(without body). I only have subject. If I do echo "$var" I am getting content of file normaly.

If I put "$var" in subject I am getting mail, in subject there is one line of file content and in message body I am getting other line and this text Message-ID: <4ef89fd0.IBaQ8Nx7ioCRAdjo%info@apif.net>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


Does anyone know what can be problem. Thank's

Nermal 12-27-2011 04:45 AM

You could try:

Code:


cat $f | mailx -s "Subject" user@domain

or:

echo "Here is the file:" | mailx -s "Subject" -a $f user@domain

The first may consider the content and process it as if you are sending it typing it in therefore lines that are ".\n" may break it.

The second will attach the file it will not be processed.


All times are GMT -5. The time now is 07:48 AM.