I want to send mail and attach all files in directory. Below doesn't work

sendMail -a | find . -name '*.*'

Create a tarball of the directory first:

tar -cvf attachments.tar.gz <directory>

Then send that file:

uuencode /path/attachments.tar.gz | sendmail -s "subject" user@domain
  • I agree with the above answer. You're piping it backwards. You want to get the collection of files (or one big zip/tgz) and pipe it to the sendmail command instead of the other way around. Dec 7 '20 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.