0

I'm using Amazon Linux. I found the following for sending the contents of a file as an attachment

cat /tmp/output.txt | mailx -s "Subject" "[email protected]"

But what I want to do is send the contents of the file as the body of the email, as opposed to an attachment. How do I do this?

2 Answers 2

0

You man use "lower level" sendmail program.

#!/bin/sh
# cat - ... <<END - cat reads "here document" via its stdin
# empty line after email headers IS REQUIRED

cat - /tmp/output.txt <<END | /usr/sbin/sendmail -- [email protected]
Subject: Subject
To: [email protected]

END
0

It doesn't your example sends just /tmp/output.txt as message body. Maybe content of this file is formatted as an attachment?

Try with:

echo "Test message" | mailx -s "Subject" "[email protected]"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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