I tried with this command but no luck.

echo 'These are contents of my mail' | mailx -s 'This is my email subject' -a /home/user/Desktop/data.zip mail_id@example.com

Any suggestion?

  • What were the results? – Jeff Schaller Mar 11 '20 at 9:48
  • did not display any reults either the error, but did not receive mail – Ramesh Mar 11 '20 at 10:16
  • I also tried as below, does not give any error either it sends the report ( echo "Hi,\nPlease find attached , the report of script \nThank You";uuencode Mahi.zip Mahireport.zip ) | mail -s "these are the script - Report" -r mail_id@example.com – Ramesh Mar 11 '20 at 10:37
  • These would all be excellent edits to your question. – Jeff Schaller Mar 11 '20 at 10:39

From the manpage:

   -A, --attach=FILE
          attach FILE

   -a, --append=HEADER: VALUE append given header to the message being sent

So you want -A, not -a. Surprising no errormessage was produced for the malformed header; here it produces:

mailx: Invalid header: invalid_header
  • When i use -A i get error as "Account testfile.zip does not exist.", but i have the zip file. echo 'These are contents of my mail' | mailx -s 'This is my email subject' -A testfile.zip user@in.example.com Account testfile.zip does not exist. – Ramesh Mar 12 '20 at 5:59
  • Looks like you're using a different mailx than i am. Mine is from the (debian) package mailutis. – bavang Mar 13 '20 at 19:32

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.