- Red Hat Enterprise Linux 6
How can I attach a file to an email using the command line in RHEL 6?
Why when upgrading to
mailx 12.xthe way
uuencodedemail attachments are displayed in an email client changes from being shown as an attachment to being displayed inline?
mailxsends uuencoded attachments as body in the mail?
mutt -a or
yum install mutt
echo "MESSAGE BODY" | mutt -s "SUBJECT" -a "FILEPATH" "ANOTHERFILE" -- USER@DOM.TLD
- Leave off the
echocompletely to enter message body interactively
- Leave off the
echo "MESSAGE BODY" | mailx -s "SUBJECT" -a "FILEPATH" -a "ANOTHERFILE" USER@DOM.TLD
Leave off the
echocompletely to enter message body interactively (press Ctrl-d when finished)
Skip specifying a message body by using an
echowith no arguments (
echo | mailx ...) or by dropping
/dev/nullvia stdin (
mailx ... USER@DOM.TLD </dev/null)
For sending attachments in RHEL 5, see:
How to attach a file to an email using command line in RHEL 5?
There was a package change between RHEL 5 & RHEL 6. RHEL 5 had bsd-mailx & RHEL 6 has Heirloom mailx. (That is to say, this is not a bug in
uuencodebut simply a change in the mailx package.)
In the newer version of mailx the headers that are used in outgoing email changed from:
From: Date: To: Subject:
From: Date: To: Subject: User-Agent: MIME-Version: Content-Type: Content-Transfer-Encoding:
The old bsd-mailx (same as RHEL 5) package is available (unsupported) for RHEL 6 via EPEL; however, note that any scripts that require the old bsd-mailx package should be updated to use the new mailx (bsd-mailx will not be available in RHEL 7 and later)
- Check the headers in the received email. Email that has been sent with the old
uuencodemethod of attachment will have a content type of
Content-Type: text/plainwith no boundary. Email that has attachments using the newer
mailx -aswitch will have
Content-Type: multipart/mixed; boundary="= ...."headers.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.