How to add subject line when sending email output of find using ssmtp

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I got a script running (as cronjob) that will list the files in a folder before doing a Rsync job and emailing me the list. How can I add a subject line.



find /path/to/folder/ -type f -size +1M -name "*.mov" -printf "%fn" | ssmtp my_email@domain.com


I tried this with -s "Subject" but no luck. It only works if I put the subject in a text file and call this text file



find /path/to/folder/ -type f -size +1M -name "*.mov" -printf "%fn" | my_email@domain.com < /path/to/file/subjectline.txt


But than it won't add the search results in the Message.



Any thoughts on what I am doing wrong,



Bas










share|improve this question



























    up vote
    1
    down vote

    favorite












    I got a script running (as cronjob) that will list the files in a folder before doing a Rsync job and emailing me the list. How can I add a subject line.



    find /path/to/folder/ -type f -size +1M -name "*.mov" -printf "%fn" | ssmtp my_email@domain.com


    I tried this with -s "Subject" but no luck. It only works if I put the subject in a text file and call this text file



    find /path/to/folder/ -type f -size +1M -name "*.mov" -printf "%fn" | my_email@domain.com < /path/to/file/subjectline.txt


    But than it won't add the search results in the Message.



    Any thoughts on what I am doing wrong,



    Bas










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I got a script running (as cronjob) that will list the files in a folder before doing a Rsync job and emailing me the list. How can I add a subject line.



      find /path/to/folder/ -type f -size +1M -name "*.mov" -printf "%fn" | ssmtp my_email@domain.com


      I tried this with -s "Subject" but no luck. It only works if I put the subject in a text file and call this text file



      find /path/to/folder/ -type f -size +1M -name "*.mov" -printf "%fn" | my_email@domain.com < /path/to/file/subjectline.txt


      But than it won't add the search results in the Message.



      Any thoughts on what I am doing wrong,



      Bas










      share|improve this question















      I got a script running (as cronjob) that will list the files in a folder before doing a Rsync job and emailing me the list. How can I add a subject line.



      find /path/to/folder/ -type f -size +1M -name "*.mov" -printf "%fn" | ssmtp my_email@domain.com


      I tried this with -s "Subject" but no luck. It only works if I put the subject in a text file and call this text file



      find /path/to/folder/ -type f -size +1M -name "*.mov" -printf "%fn" | my_email@domain.com < /path/to/file/subjectline.txt


      But than it won't add the search results in the Message.



      Any thoughts on what I am doing wrong,



      Bas







      shell find cron ssmtp






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '15 at 8:48









      RobertL

      4,768624




      4,768624










      asked Nov 20 '15 at 7:02









      Bas

      612




      612




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote













          Try this:




          echo To: my_email@domain.com
          echo From: from_email@example.com
          echo Subject: mov files greater than 1M
          echo
          find /path/to/folder/ -type f -size +1M -name "*.mov"
          | ssmtp my_email@domain.com


          You don't need the printf on find.






          share|improve this answer




















          • Awesome that works really well. The only reason I had the -printf "%fn" was to trim of the full path and just have the filenames. Thank you very much that was really helpful.
            – Bas
            Nov 20 '15 at 11:21


















          up vote
          0
          down vote













          Thanks, works



          # cat /opt/mail.sh
          #!/bin/bash
          echo "Subject: from pc" > /root/myip.txt
          curl -s checkip.dyndns.org >> /root/myip.txt
          sleep 10
          /usr/sbin/ssmtp email@domain.org < /root/myip.txt

          # cat /root/myip.txt
          Subject: from pc
          <html><head><title>Current IP Check</title></head><body>Current IP Address: xxx.xxx.xxx.xxx</body></html>




          share








          New contributor




          Igors Jakimenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















            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',
            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%2f244294%2fhow-to-add-subject-line-when-sending-email-output-of-find-using-ssmtp%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote













            Try this:




            echo To: my_email@domain.com
            echo From: from_email@example.com
            echo Subject: mov files greater than 1M
            echo
            find /path/to/folder/ -type f -size +1M -name "*.mov"
            | ssmtp my_email@domain.com


            You don't need the printf on find.






            share|improve this answer




















            • Awesome that works really well. The only reason I had the -printf "%fn" was to trim of the full path and just have the filenames. Thank you very much that was really helpful.
              – Bas
              Nov 20 '15 at 11:21















            up vote
            3
            down vote













            Try this:




            echo To: my_email@domain.com
            echo From: from_email@example.com
            echo Subject: mov files greater than 1M
            echo
            find /path/to/folder/ -type f -size +1M -name "*.mov"
            | ssmtp my_email@domain.com


            You don't need the printf on find.






            share|improve this answer




















            • Awesome that works really well. The only reason I had the -printf "%fn" was to trim of the full path and just have the filenames. Thank you very much that was really helpful.
              – Bas
              Nov 20 '15 at 11:21













            up vote
            3
            down vote










            up vote
            3
            down vote









            Try this:




            echo To: my_email@domain.com
            echo From: from_email@example.com
            echo Subject: mov files greater than 1M
            echo
            find /path/to/folder/ -type f -size +1M -name "*.mov"
            | ssmtp my_email@domain.com


            You don't need the printf on find.






            share|improve this answer












            Try this:




            echo To: my_email@domain.com
            echo From: from_email@example.com
            echo Subject: mov files greater than 1M
            echo
            find /path/to/folder/ -type f -size +1M -name "*.mov"
            | ssmtp my_email@domain.com


            You don't need the printf on find.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 20 '15 at 7:18









            RobertL

            4,768624




            4,768624











            • Awesome that works really well. The only reason I had the -printf "%fn" was to trim of the full path and just have the filenames. Thank you very much that was really helpful.
              – Bas
              Nov 20 '15 at 11:21

















            • Awesome that works really well. The only reason I had the -printf "%fn" was to trim of the full path and just have the filenames. Thank you very much that was really helpful.
              – Bas
              Nov 20 '15 at 11:21
















            Awesome that works really well. The only reason I had the -printf "%fn" was to trim of the full path and just have the filenames. Thank you very much that was really helpful.
            – Bas
            Nov 20 '15 at 11:21





            Awesome that works really well. The only reason I had the -printf "%fn" was to trim of the full path and just have the filenames. Thank you very much that was really helpful.
            – Bas
            Nov 20 '15 at 11:21













            up vote
            0
            down vote













            Thanks, works



            # cat /opt/mail.sh
            #!/bin/bash
            echo "Subject: from pc" > /root/myip.txt
            curl -s checkip.dyndns.org >> /root/myip.txt
            sleep 10
            /usr/sbin/ssmtp email@domain.org < /root/myip.txt

            # cat /root/myip.txt
            Subject: from pc
            <html><head><title>Current IP Check</title></head><body>Current IP Address: xxx.xxx.xxx.xxx</body></html>




            share








            New contributor




            Igors Jakimenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















              up vote
              0
              down vote













              Thanks, works



              # cat /opt/mail.sh
              #!/bin/bash
              echo "Subject: from pc" > /root/myip.txt
              curl -s checkip.dyndns.org >> /root/myip.txt
              sleep 10
              /usr/sbin/ssmtp email@domain.org < /root/myip.txt

              # cat /root/myip.txt
              Subject: from pc
              <html><head><title>Current IP Check</title></head><body>Current IP Address: xxx.xxx.xxx.xxx</body></html>




              share








              New contributor




              Igors Jakimenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.



















                up vote
                0
                down vote










                up vote
                0
                down vote









                Thanks, works



                # cat /opt/mail.sh
                #!/bin/bash
                echo "Subject: from pc" > /root/myip.txt
                curl -s checkip.dyndns.org >> /root/myip.txt
                sleep 10
                /usr/sbin/ssmtp email@domain.org < /root/myip.txt

                # cat /root/myip.txt
                Subject: from pc
                <html><head><title>Current IP Check</title></head><body>Current IP Address: xxx.xxx.xxx.xxx</body></html>




                share








                New contributor




                Igors Jakimenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                Thanks, works



                # cat /opt/mail.sh
                #!/bin/bash
                echo "Subject: from pc" > /root/myip.txt
                curl -s checkip.dyndns.org >> /root/myip.txt
                sleep 10
                /usr/sbin/ssmtp email@domain.org < /root/myip.txt

                # cat /root/myip.txt
                Subject: from pc
                <html><head><title>Current IP Check</title></head><body>Current IP Address: xxx.xxx.xxx.xxx</body></html>





                share








                New contributor




                Igors Jakimenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.








                share


                share






                New contributor




                Igors Jakimenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 6 mins ago









                Igors Jakimenko

                1




                1




                New contributor




                Igors Jakimenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Igors Jakimenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Igors Jakimenko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f244294%2fhow-to-add-subject-line-when-sending-email-output-of-find-using-ssmtp%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?