in reply to Email error checking

For the $msg->sent part of the subroutine I have tried using or warn and printing to a file with no success.

Either use warn or print.

To print to a file, you need to specify the filehandle on the print line. The file needs to be open first, so first use
    open( FILEHANDLE, ">> $filename" ) or die qq(unable to open "$filename" because of: $!);
to achieve that.

What did you try to print to file?

Cheers, Sören