How to attach a file to an email using command line in RHEL 5?

Solution verified - Updated on

Request a new translation or translation update

A translation for your language preference does not exist. Click below to request a translation for your selected language.

Submit request

Environment

  • Red Hat Enterprise Linux (RHEL) 5

Issue

  • How can I attach a file to an email using command line in Red Hat Enterprise Linux 5?

Resolution

Either use mutt or pipe output from uuencode to mail

  • mutt

    1. yum install mutt

    2. echo "Message body here" | mutt -s "SUBJECT" -a "FILEPATH" -a "ANOTHERFILE" USER@DOM.TLD

  • uuencode + mail

    1. yum install sharutils

    2. uuencode "FILEPATH" "SHORTNAME" | mail -s "SUBJECT" USER@DOM.TLD

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.