Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells

Sending Attachments Using Mailx

Submitted by on December 3, 2014 – 2:32 pm

Sometimes it’s just better to attach a file to your email than to “cat” the contents into the email body. Later versions of mailx support the “-a” option for handling attachments. With the older mailx you will need the “uuencode” utility installed. On CentOS/RHEL you can install it by doing this:

yum install sharutils

To send the actual attachment:
uuencode filename.txt filename.txt | mailx -s "Subject" user@domain.com

Nice and easy.

Another way of sending attachments is to use Mutt (yum -y install mutt):

echo "message body" | mutt -a "/tmp/attachment.txt" -s "subject" -- recipient@domain.com

 

Print Friendly, PDF & Email

Leave a Reply