in reply to printing output of a perl script to the Email body

The easiest approach is to wrap the script in a second script that runs the first one in (say) backticks and then sends the output via MIME::Lite.

use MIME::Lite; my $output = `other_script.pl 2>&1`; $msg = MIME::Lite->new( From => 'me@myhost.com', To => 'you@yourhost.com', Cc => 'some@other.com, some@more.com', Subject => 'Output of a script...', Type => 'multipart/mixed' ); ### Add parts (each "attach" has same arguments as "new"): $msg->attach( Type => 'TEXT', Data => $output );

Replies are listed 'Best First'.
Re^2: printing output of a perl script to the Email body
by Bod (Parson) on Jan 29, 2021 at 10:59 UTC

    Like Corion, I would use MIME::Lite but...

    The documentation warns:
    "MIME::Lite is not recommended by its current maintainer."

    For that reason, I started looking at alternatives but didn't really get very far - mainly because of familiarity with the easy to use MIME:Lite module.

      Yes, it's not recommended by its maintainer, but it still works very well, and I haven't encountered a case where I had to investigate a different module.

      Also, the module won't be going anywhere and gets a release from time to time. The issues with patches are somewhat likely to be worked on.

        Yes, it's not recommended by its maintainer, but it still works very well, and I haven't encountered a case where I had to investigate a different module

        The only reason I was looking for a replacement module was the comment in the documentation...
        Given your endorsement, I shall give up that search as I find MIME::Lite a very useful module that does most things I ever want with email.