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: