in reply to Re: Cant send Email
in thread Cant send Email

Besides the question of whether this solves the ability to sendmail on localhost, this code has serious duplication. I would read all four variables from @_, and then determine what to do based on whether the fourth variable has a value or not. Using prototypes for subroutines is deprecated, I would avoid it.

use MIME:Lite; sub _mailme { my ($to, $subject, $runlog, $mksysblog) = @_; $msg = MIME::Lite->new( From => 'MAILER-DAEMON root', To => "$to", Subject => "$subject", Type => 'multipart/related' ); $msg->attach( Type =>'TEXT/html', Data =>"See attachment!" ); $msg->attach( Type => 'TEXT', Disposition => 'attachment', Path => "$runlog", Filename => "$runlog" ); if ( $mksysblog ) { $msg->attach( Type => 'TEXT', Disposition => 'attachment', Path => "$mksysblog", Filename => "$mksysblog" ); } $msg->send; }

As Occam said: Entia non sunt multiplicanda praeter necessitatem.