What are some better options for encoding email attachments than uuencode in a bash script?












4















I'm referencing my original post in which I was asking a question about argument placement pertaining to $2 $3 etc, and eventually ${@:2}. It was mentioned that there are better methods to encode email attachments.



Note, I used uname -or to figure out 2.6.32-400.26.3.el5uek GNU/Linux.



I used the command within a bash script to attach a file to an email, and have it in a couple other scripts as well. However, a few of our machines do not even support uuencode, so what are some better options for attaching files to emails than uuencode?










share|improve this question




















  • 3





    MIME (base64) encoding is used for this purpose.

    – Thomas Dickey
    Jul 12 '17 at 20:38






  • 3





    Your implementation of mail may include -a to attach a file, in which case the encoding is handled under the hood for you.

    – DopeGhoti
    Jul 12 '17 at 20:47











  • Possible duplicate of how to send multiple attachment in 1 email using uuencode, which actually offers a MIME-based alternative to uuencode.

    – roaima
    Jul 12 '17 at 22:15


















4















I'm referencing my original post in which I was asking a question about argument placement pertaining to $2 $3 etc, and eventually ${@:2}. It was mentioned that there are better methods to encode email attachments.



Note, I used uname -or to figure out 2.6.32-400.26.3.el5uek GNU/Linux.



I used the command within a bash script to attach a file to an email, and have it in a couple other scripts as well. However, a few of our machines do not even support uuencode, so what are some better options for attaching files to emails than uuencode?










share|improve this question




















  • 3





    MIME (base64) encoding is used for this purpose.

    – Thomas Dickey
    Jul 12 '17 at 20:38






  • 3





    Your implementation of mail may include -a to attach a file, in which case the encoding is handled under the hood for you.

    – DopeGhoti
    Jul 12 '17 at 20:47











  • Possible duplicate of how to send multiple attachment in 1 email using uuencode, which actually offers a MIME-based alternative to uuencode.

    – roaima
    Jul 12 '17 at 22:15
















4












4








4








I'm referencing my original post in which I was asking a question about argument placement pertaining to $2 $3 etc, and eventually ${@:2}. It was mentioned that there are better methods to encode email attachments.



Note, I used uname -or to figure out 2.6.32-400.26.3.el5uek GNU/Linux.



I used the command within a bash script to attach a file to an email, and have it in a couple other scripts as well. However, a few of our machines do not even support uuencode, so what are some better options for attaching files to emails than uuencode?










share|improve this question
















I'm referencing my original post in which I was asking a question about argument placement pertaining to $2 $3 etc, and eventually ${@:2}. It was mentioned that there are better methods to encode email attachments.



Note, I used uname -or to figure out 2.6.32-400.26.3.el5uek GNU/Linux.



I used the command within a bash script to attach a file to an email, and have it in a couple other scripts as well. However, a few of our machines do not even support uuencode, so what are some better options for attaching files to emails than uuencode?







linux shell-script email character-encoding






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 43 mins ago









Rui F Ribeiro

41.8k1483142




41.8k1483142










asked Jul 12 '17 at 20:36









EmileEmile

9810




9810








  • 3





    MIME (base64) encoding is used for this purpose.

    – Thomas Dickey
    Jul 12 '17 at 20:38






  • 3





    Your implementation of mail may include -a to attach a file, in which case the encoding is handled under the hood for you.

    – DopeGhoti
    Jul 12 '17 at 20:47











  • Possible duplicate of how to send multiple attachment in 1 email using uuencode, which actually offers a MIME-based alternative to uuencode.

    – roaima
    Jul 12 '17 at 22:15
















  • 3





    MIME (base64) encoding is used for this purpose.

    – Thomas Dickey
    Jul 12 '17 at 20:38






  • 3





    Your implementation of mail may include -a to attach a file, in which case the encoding is handled under the hood for you.

    – DopeGhoti
    Jul 12 '17 at 20:47











  • Possible duplicate of how to send multiple attachment in 1 email using uuencode, which actually offers a MIME-based alternative to uuencode.

    – roaima
    Jul 12 '17 at 22:15










3




3





MIME (base64) encoding is used for this purpose.

– Thomas Dickey
Jul 12 '17 at 20:38





MIME (base64) encoding is used for this purpose.

– Thomas Dickey
Jul 12 '17 at 20:38




3




3





Your implementation of mail may include -a to attach a file, in which case the encoding is handled under the hood for you.

– DopeGhoti
Jul 12 '17 at 20:47





Your implementation of mail may include -a to attach a file, in which case the encoding is handled under the hood for you.

– DopeGhoti
Jul 12 '17 at 20:47













Possible duplicate of how to send multiple attachment in 1 email using uuencode, which actually offers a MIME-based alternative to uuencode.

– roaima
Jul 12 '17 at 22:15







Possible duplicate of how to send multiple attachment in 1 email using uuencode, which actually offers a MIME-based alternative to uuencode.

– roaima
Jul 12 '17 at 22:15












4 Answers
4






active

oldest

votes


















2














I prefer using mpack to send attachments as MIME



as in:



mpack -s "message" file email@example.com



Name



mpack - pack a file in MIME format Synopsis



mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c
content-type ] file address ... mpack [ -s subject ] [ -d
descriptionfile ] [ -m maxsize ] [ -c content-type ] -o outputfile
file mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c
content-type ] -n newsgroups file Description



The mpack program encodes the the named file in one or more MIME
messages. The resulting messages are mailed to one or more recipients,
written to a named file or set of files, or posted to a set of
newsgroups.







share|improve this answer































    1














    You know I find that the following works just fine for files in either TEXT or binary:



     mailx -s SUBJECT -a FILE1 -a FILE2 ... USERNAME


    It basically does the MIME encoding automatically and.....even M$ Outlook does the right thing with such a message.






    share|improve this answer































      0














      If missing uuencode, this perl hack does pretty much the same thing.



      Credit goes to Perl Monks site



      perl -ple"BEGIN{ $/=45} $_ = pack 'u', $_" file





      share|improve this answer
























      • The question is about avoiding use of uuencode. The back-story is that a MIME-compliant solution is being sought.

        – roaima
        Jul 12 '17 at 22:12





















      0














      You could 7z or zip or tar.wz or similar to get a compressed list of files.



      Then the compressed list of files could be converted to hex. Use od hd or xxd:



      $ xxd -p compressedfile.7z > ToBeMailedFile


      Send the file attached to your email.



      Convert back the file:



      $ xxd -p -r ToBeMailedFile > compressedfile.7z


      Expand the file to the list of files.



      As HEX pass every web limitation of characters allowed, the file will pass.

      As the list of files is compressed before being sent, there is a gain of size.

      The compressed file could be also encrypted.
      Several diferent tools could be used to process the data. Only the conversion of HEX to BIN needs xxd. So, freedom of tools.






      share|improve this answer
























      • xxd is less efficient; it requires 103% more space than the input, vs only 37% more for uuencode and 35% for base64. Demo: i=/bin/dash o=/dev/stdout ; wc -c $i <(uuencode $i $o) <(uuencode -m $i $o) <(xxd -p $i) | head -n -1

        – agc
        Sep 23 '17 at 7:33













      • @agc You may be correct; however: The question specified that uuencode was not available: better options for attaching files to emails than uuencode?

        – Arrow
        Sep 24 '17 at 3:00











      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "106"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f378066%2fwhat-are-some-better-options-for-encoding-email-attachments-than-uuencode-in-a-b%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      I prefer using mpack to send attachments as MIME



      as in:



      mpack -s "message" file email@example.com



      Name



      mpack - pack a file in MIME format Synopsis



      mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c
      content-type ] file address ... mpack [ -s subject ] [ -d
      descriptionfile ] [ -m maxsize ] [ -c content-type ] -o outputfile
      file mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c
      content-type ] -n newsgroups file Description



      The mpack program encodes the the named file in one or more MIME
      messages. The resulting messages are mailed to one or more recipients,
      written to a named file or set of files, or posted to a set of
      newsgroups.







      share|improve this answer




























        2














        I prefer using mpack to send attachments as MIME



        as in:



        mpack -s "message" file email@example.com



        Name



        mpack - pack a file in MIME format Synopsis



        mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c
        content-type ] file address ... mpack [ -s subject ] [ -d
        descriptionfile ] [ -m maxsize ] [ -c content-type ] -o outputfile
        file mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c
        content-type ] -n newsgroups file Description



        The mpack program encodes the the named file in one or more MIME
        messages. The resulting messages are mailed to one or more recipients,
        written to a named file or set of files, or posted to a set of
        newsgroups.







        share|improve this answer


























          2












          2








          2







          I prefer using mpack to send attachments as MIME



          as in:



          mpack -s "message" file email@example.com



          Name



          mpack - pack a file in MIME format Synopsis



          mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c
          content-type ] file address ... mpack [ -s subject ] [ -d
          descriptionfile ] [ -m maxsize ] [ -c content-type ] -o outputfile
          file mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c
          content-type ] -n newsgroups file Description



          The mpack program encodes the the named file in one or more MIME
          messages. The resulting messages are mailed to one or more recipients,
          written to a named file or set of files, or posted to a set of
          newsgroups.







          share|improve this answer













          I prefer using mpack to send attachments as MIME



          as in:



          mpack -s "message" file email@example.com



          Name



          mpack - pack a file in MIME format Synopsis



          mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c
          content-type ] file address ... mpack [ -s subject ] [ -d
          descriptionfile ] [ -m maxsize ] [ -c content-type ] -o outputfile
          file mpack [ -s subject ] [ -d descriptionfile ] [ -m maxsize ] [ -c
          content-type ] -n newsgroups file Description



          The mpack program encodes the the named file in one or more MIME
          messages. The resulting messages are mailed to one or more recipients,
          written to a named file or set of files, or posted to a set of
          newsgroups.








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 12 '17 at 21:41









          Rui F RibeiroRui F Ribeiro

          41.8k1483142




          41.8k1483142

























              1














              You know I find that the following works just fine for files in either TEXT or binary:



               mailx -s SUBJECT -a FILE1 -a FILE2 ... USERNAME


              It basically does the MIME encoding automatically and.....even M$ Outlook does the right thing with such a message.






              share|improve this answer




























                1














                You know I find that the following works just fine for files in either TEXT or binary:



                 mailx -s SUBJECT -a FILE1 -a FILE2 ... USERNAME


                It basically does the MIME encoding automatically and.....even M$ Outlook does the right thing with such a message.






                share|improve this answer


























                  1












                  1








                  1







                  You know I find that the following works just fine for files in either TEXT or binary:



                   mailx -s SUBJECT -a FILE1 -a FILE2 ... USERNAME


                  It basically does the MIME encoding automatically and.....even M$ Outlook does the right thing with such a message.






                  share|improve this answer













                  You know I find that the following works just fine for files in either TEXT or binary:



                   mailx -s SUBJECT -a FILE1 -a FILE2 ... USERNAME


                  It basically does the MIME encoding automatically and.....even M$ Outlook does the right thing with such a message.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 12 '17 at 23:28









                  mdpcmdpc

                  5,07621838




                  5,07621838























                      0














                      If missing uuencode, this perl hack does pretty much the same thing.



                      Credit goes to Perl Monks site



                      perl -ple"BEGIN{ $/=45} $_ = pack 'u', $_" file





                      share|improve this answer
























                      • The question is about avoiding use of uuencode. The back-story is that a MIME-compliant solution is being sought.

                        – roaima
                        Jul 12 '17 at 22:12


















                      0














                      If missing uuencode, this perl hack does pretty much the same thing.



                      Credit goes to Perl Monks site



                      perl -ple"BEGIN{ $/=45} $_ = pack 'u', $_" file





                      share|improve this answer
























                      • The question is about avoiding use of uuencode. The back-story is that a MIME-compliant solution is being sought.

                        – roaima
                        Jul 12 '17 at 22:12
















                      0












                      0








                      0







                      If missing uuencode, this perl hack does pretty much the same thing.



                      Credit goes to Perl Monks site



                      perl -ple"BEGIN{ $/=45} $_ = pack 'u', $_" file





                      share|improve this answer













                      If missing uuencode, this perl hack does pretty much the same thing.



                      Credit goes to Perl Monks site



                      perl -ple"BEGIN{ $/=45} $_ = pack 'u', $_" file






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jul 12 '17 at 20:45









                      stevesteve

                      14.3k22653




                      14.3k22653













                      • The question is about avoiding use of uuencode. The back-story is that a MIME-compliant solution is being sought.

                        – roaima
                        Jul 12 '17 at 22:12





















                      • The question is about avoiding use of uuencode. The back-story is that a MIME-compliant solution is being sought.

                        – roaima
                        Jul 12 '17 at 22:12



















                      The question is about avoiding use of uuencode. The back-story is that a MIME-compliant solution is being sought.

                      – roaima
                      Jul 12 '17 at 22:12







                      The question is about avoiding use of uuencode. The back-story is that a MIME-compliant solution is being sought.

                      – roaima
                      Jul 12 '17 at 22:12













                      0














                      You could 7z or zip or tar.wz or similar to get a compressed list of files.



                      Then the compressed list of files could be converted to hex. Use od hd or xxd:



                      $ xxd -p compressedfile.7z > ToBeMailedFile


                      Send the file attached to your email.



                      Convert back the file:



                      $ xxd -p -r ToBeMailedFile > compressedfile.7z


                      Expand the file to the list of files.



                      As HEX pass every web limitation of characters allowed, the file will pass.

                      As the list of files is compressed before being sent, there is a gain of size.

                      The compressed file could be also encrypted.
                      Several diferent tools could be used to process the data. Only the conversion of HEX to BIN needs xxd. So, freedom of tools.






                      share|improve this answer
























                      • xxd is less efficient; it requires 103% more space than the input, vs only 37% more for uuencode and 35% for base64. Demo: i=/bin/dash o=/dev/stdout ; wc -c $i <(uuencode $i $o) <(uuencode -m $i $o) <(xxd -p $i) | head -n -1

                        – agc
                        Sep 23 '17 at 7:33













                      • @agc You may be correct; however: The question specified that uuencode was not available: better options for attaching files to emails than uuencode?

                        – Arrow
                        Sep 24 '17 at 3:00
















                      0














                      You could 7z or zip or tar.wz or similar to get a compressed list of files.



                      Then the compressed list of files could be converted to hex. Use od hd or xxd:



                      $ xxd -p compressedfile.7z > ToBeMailedFile


                      Send the file attached to your email.



                      Convert back the file:



                      $ xxd -p -r ToBeMailedFile > compressedfile.7z


                      Expand the file to the list of files.



                      As HEX pass every web limitation of characters allowed, the file will pass.

                      As the list of files is compressed before being sent, there is a gain of size.

                      The compressed file could be also encrypted.
                      Several diferent tools could be used to process the data. Only the conversion of HEX to BIN needs xxd. So, freedom of tools.






                      share|improve this answer
























                      • xxd is less efficient; it requires 103% more space than the input, vs only 37% more for uuencode and 35% for base64. Demo: i=/bin/dash o=/dev/stdout ; wc -c $i <(uuencode $i $o) <(uuencode -m $i $o) <(xxd -p $i) | head -n -1

                        – agc
                        Sep 23 '17 at 7:33













                      • @agc You may be correct; however: The question specified that uuencode was not available: better options for attaching files to emails than uuencode?

                        – Arrow
                        Sep 24 '17 at 3:00














                      0












                      0








                      0







                      You could 7z or zip or tar.wz or similar to get a compressed list of files.



                      Then the compressed list of files could be converted to hex. Use od hd or xxd:



                      $ xxd -p compressedfile.7z > ToBeMailedFile


                      Send the file attached to your email.



                      Convert back the file:



                      $ xxd -p -r ToBeMailedFile > compressedfile.7z


                      Expand the file to the list of files.



                      As HEX pass every web limitation of characters allowed, the file will pass.

                      As the list of files is compressed before being sent, there is a gain of size.

                      The compressed file could be also encrypted.
                      Several diferent tools could be used to process the data. Only the conversion of HEX to BIN needs xxd. So, freedom of tools.






                      share|improve this answer













                      You could 7z or zip or tar.wz or similar to get a compressed list of files.



                      Then the compressed list of files could be converted to hex. Use od hd or xxd:



                      $ xxd -p compressedfile.7z > ToBeMailedFile


                      Send the file attached to your email.



                      Convert back the file:



                      $ xxd -p -r ToBeMailedFile > compressedfile.7z


                      Expand the file to the list of files.



                      As HEX pass every web limitation of characters allowed, the file will pass.

                      As the list of files is compressed before being sent, there is a gain of size.

                      The compressed file could be also encrypted.
                      Several diferent tools could be used to process the data. Only the conversion of HEX to BIN needs xxd. So, freedom of tools.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jul 13 '17 at 0:02









                      ArrowArrow

                      2,490218




                      2,490218













                      • xxd is less efficient; it requires 103% more space than the input, vs only 37% more for uuencode and 35% for base64. Demo: i=/bin/dash o=/dev/stdout ; wc -c $i <(uuencode $i $o) <(uuencode -m $i $o) <(xxd -p $i) | head -n -1

                        – agc
                        Sep 23 '17 at 7:33













                      • @agc You may be correct; however: The question specified that uuencode was not available: better options for attaching files to emails than uuencode?

                        – Arrow
                        Sep 24 '17 at 3:00



















                      • xxd is less efficient; it requires 103% more space than the input, vs only 37% more for uuencode and 35% for base64. Demo: i=/bin/dash o=/dev/stdout ; wc -c $i <(uuencode $i $o) <(uuencode -m $i $o) <(xxd -p $i) | head -n -1

                        – agc
                        Sep 23 '17 at 7:33













                      • @agc You may be correct; however: The question specified that uuencode was not available: better options for attaching files to emails than uuencode?

                        – Arrow
                        Sep 24 '17 at 3:00

















                      xxd is less efficient; it requires 103% more space than the input, vs only 37% more for uuencode and 35% for base64. Demo: i=/bin/dash o=/dev/stdout ; wc -c $i <(uuencode $i $o) <(uuencode -m $i $o) <(xxd -p $i) | head -n -1

                      – agc
                      Sep 23 '17 at 7:33







                      xxd is less efficient; it requires 103% more space than the input, vs only 37% more for uuencode and 35% for base64. Demo: i=/bin/dash o=/dev/stdout ; wc -c $i <(uuencode $i $o) <(uuencode -m $i $o) <(xxd -p $i) | head -n -1

                      – agc
                      Sep 23 '17 at 7:33















                      @agc You may be correct; however: The question specified that uuencode was not available: better options for attaching files to emails than uuencode?

                      – Arrow
                      Sep 24 '17 at 3:00





                      @agc You may be correct; however: The question specified that uuencode was not available: better options for attaching files to emails than uuencode?

                      – Arrow
                      Sep 24 '17 at 3:00


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f378066%2fwhat-are-some-better-options-for-encoding-email-attachments-than-uuencode-in-a-b%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      CARDNET

                      Boot-repair Failure: Unable to locate package grub-common:i386

                      Aws NAT - Aws IGW- Aws router