4

We could do this using uuencode:

uuencode actual_file display_file_name | mailx testemail@org.com

Could you please advice how this can be done using mailx -a?

The only option seems to be to copy file with a different name, and then try.

peterh
  • 9,731

1 Answers1

2

When you are using -a option, the mailx program will do all the necessary conversions to base64 and then to MIME format for you. No need to use uuencode

echo | mailx -a actual_file testemail@org.com

The only trick is that for some reason mailx does not work if you put -a actual_file after the recipient email address.

Note that using echo command makes sure that mailx will not ask you to enter subject and message body manually.

p.s. replying to your comment... AFAIK, there is no such option in mailx program to provide different display name. In order to attach a file such that it is shown under a different name in e-mail, you can do

ln -s actual_file attached_file
echo | mailx -a attached_file testemail@org.com
rm -f attached_file
John Smith
  • 2,779
  • Hello John, Firstly, Thanks for your reply. My question was, how do we show a different file name on the email? Eg: If I am attaching 1234.log onto the email, I would typically like to show it with a different name, say : testing_details.log . This can be done using uuencode, but couldn't find any way to do this using mailx -a – user252749 Sep 25 '17 at 13:04
  • ah... now got what you want. added the code to my reply. – John Smith Sep 25 '17 at 14:21
  • on this site "thanks" are expressed by marking the answer as "accepted" if you are satisfied with it :) – John Smith Sep 26 '17 at 11:31
  • 1
    Instead of -a use -A to add attachment. – ssasa Mar 13 '20 at 11:46