1 package SL::Mailer::Sendmail;
 
   9 use parent qw(Rose::Object);
 
  11 use Rose::Object::MakeMethods::Generic
 
  13   scalar => [ qw(myconfig mailer form) ]
 
  19   Rose::Object::init(@_);
 
  21   my $email         =  $::locale->is_utf8 ? Encode::encode('utf-8', $self->myconfig->{email}) : $self->myconfig->{email};
 
  22   $email            =~ s/[^\w\.\-\+=@]//ig;
 
  24   my %temp_form     = ( %{ $self->form }, myconfig_email => $email );
 
  25   my $template      = SL::Template::create(type => 'ShellCommand', form => \%temp_form);
 
  26   my $sendmail      = $::lx_office_conf{applications}->{sendmail} || $::lx_office_conf{mail_delivery}->{sendmail} || "sendmail -t";
 
  27   $sendmail         = $template->parse_block($sendmail);
 
  29   $self->{sendmail} = IO::File->new("|$sendmail") || die "sendmail($sendmail): $!";
 
  30   $self->{sendmail}->binmode(':utf8') if $::locale->is_utf8;
 
  39   $self->{sendmail}->print(@_);
 
  44   $self->{sendmail}->close;
 
  45   delete $self->{sendmail};
 
  48 sub keep_from_header {