Sending Mail Body and Attachment Using Mailx - Linux

Sending simple message body + file attachment using Linux Mailx

The usual way is to use uuencode for the attachments and echo for the body:

(uuencode output.txt output.txt; echo "Body of text") | mailx -s 'Subject' user@domain.com

For Solaris and AIX, you may need to put the echo statement first:

(echo "Body of text"; uuencode output.txt output.txt) | mailx -s 'Subject' user@domain.com

Send email with body and attachment with mailx

From mailx's man page :

-a file
Attach the given file to the message.

-f makes mailx process a file as if it was provided on stdin, so you encountered an error because you were providing data to mailx both through stdin and a file.

How do I send a file as an email attachment using Linux command line?

None of the mutt ones worked for me. It was thinking the email address was part of the attachment. Had to do:

echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- recipient@domain.example


Related Topics



Leave a reply



Submit