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
Resolve Relative Relocations in Partial Link
Find Command Find Directories That Were Created After a Certain Date Under Linux/Cygwin
How to Change the Permissions in Openshift Container Platform
Using $Origin to Specify the Interpreter in Elf Binaries Isn't Working
Any Reason for Using "*/" in Command "Ls -D */" to List Directories
Replace Text Between Two Lines with Contents of a File Stored in a Variable in Sed
How Can a Program Detect If It Is Running as a Systemd Daemon
Perf_Event_Open Always Returns -1
Is an Operating System Kernel an Interpeter for All Other Programs
How to Get Gcc to Skip Errors, But Still Output Them
Combine Two CSV Files Based on Common Column Using Awk or Sed
Using Pipe in Linux Using Parent and Child Process
Preventing to Bash Script from Running in Parallel or Overlap Using Cron
Determine Os from a Single Command Line Operation
Python3 Mlpy Installation Error - 'Py_Initmodule3' Was Not Declared in This Scope