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
Use Japanese characters in subject and attach file with mailx in RedHat Linux
There's a list of things you need help with here, more than I want to to handle exhaustively on a sunny Saturday afternoon. But some hints.
Quote your variables.
"$SUBJECT_1"
is a single string, whereas $SUBJECT_1
is a list of space-separated words. The second word is your email recipient, and subsequent options are also recipients.
Subject.
The basic idea is that you need to include encoding data in the subject, because email headers are only supposed to include 7-bit ASCII.
Here is a hint at how you put special characters in your Subject line.
Here is another hint.
Here is the RFC that describes in lurid detail what you need to do. Asking your favourite search engine for information about "utf8 email subject" and "rfc1522" is probably a good idea.
Email client.
Finally, rather than learning how to use MIME, consider using mutt
instead of mailx
to send your mail. Mutt has a -a
option to add attachments, making it WAY easier than constructing your own headers and body, which I'm not even sure you'd be able to do with mailx in the first place.
How do you pull text out of a file and Email it as the body in Redhat?
We ended up using the mail command instead.
$ mail –s “Subject of email” email@example.com < /text.rtf
some documentation can be found at https://www.binarytides.com/linux-mail-command-examples/ or using the "man mail" command.
How do I send stdout as an attachment via mailx?
Fixed:
( echo "Subject: ls"; ls -l ~ | uuencode att0.txt; ls -l /tmp | uuencode att1.txt) | sendmail someone@somewhere.org
Ugly, but working. What you can do.
Related Topics
Why Does Gdb Prompt "Unexpected Size of Section '.Reg-Xstate/Xxxxx' in Core File."
How to Get Window Id for Xdotool Automatically
Open Website from Within Eclipse's Internal Browser
How to Set Umask Default for an User
Clearing Large Apache Domain Logs
Is There Any General Interfaces on Linux to Simulate Mouse Movements and Click
Accept Multiple Lines of Input in a Bash Script
Bash Exit Script from Inside a Function
Gnuplot-Like Program for Timeline Data
Toolchain to Crosscompile Applications for Bbb
Difference Between "Cpu/Mem-Loads/Pp" and "Cpu/Mem-Loads/"
How to Determine a Tar Archive's Format
Make for Compiling - All *.C Files in Folders & Subfolders in Project
Qemu Simple Backend Tracing Dosen'T Print Anything
Setting Color Brightness on Linux/Xorg
Monitoring (Sniffing) /Dev/Ttyusb0 Created by Ftdi Usb Serial Converter