in reply to sending mail
Please have a look at my post here about the security issues with calling external commands. I really hope you've sanitized the variables you are interpolating into that shell command.
I really don't want to use packages for such a simple operation.
You will be doing yourself a huge favor by using a module like Email::Sender and the other Email::* modules by rjbs. Yes, even you can use CPAN! Example code.
But if you really, really want to do it in pure Perl, then at least use a piped open instead of qx + cat:
use warnings; use strict; use 5.008; my @cmd = ('mailx','-r',$EMAIL_ADMIN, '-s',"Exchange Backup Status $rptdate",$SEND_TO); die '@cmd must have more than one element' unless @cmd>1; open my $fh, '|-', @cmd or die $!; print $fh $mail_body; close $fh or die $! ? $! : $?;
|
|---|