use strict; use warnings; use Mail::Mailer; # mfile == 'Mail File' in context my $mfile = "somefile.txt"; # Override the default mailer found when the module was # installed (looks for 'mail', 'Mail' by default) my $mailer = Mail::Mailer->new("mail", "/usr/bin/mailx"); $mailer->open('From' =>'Joe User ', 'To' =>'Sally Seashells ', 'Subject'=>'Do you sell seashells by the seashore?'); open (MFILE, "<$mfile") or die "Cannot open file: $!"; print $mailer MFILE; close MFILE; close($mailer) or die "Cannot close mailer: $!"; #### package Stderr; sub new { bless {} } # Turn off stderr sub stderr_off { open(SAVEERR, ">&STDERR"); close(STDERR); } # Turn on stderr sub stderr_on { open(STDERR, ">&SAVEERR"); close(SAVEERR); } 1;