kivitendo/SL/Mailer/Sendmail.pm @ 79b7fc43
5896d8bf | Moritz Bunkus | package SL::Mailer::Sendmail;
|
||
use strict;
|
||||
93b7fa24 | Moritz Bunkus | use Encode;
|
||
5896d8bf | Moritz Bunkus | use IO::File;
|
||
use SL::Template;
|
||||
use parent qw(Rose::Object);
|
||||
use Rose::Object::MakeMethods::Generic
|
||||
(
|
||||
scalar => [ qw(myconfig mailer form) ]
|
||||
);
|
||||
sub init {
|
||||
my ($self) = @_;
|
||||
Rose::Object::init(@_);
|
||||
dbda14c2 | Moritz Bunkus | my $email = Encode::encode('utf-8', $self->myconfig->{email});
|
||
5896d8bf | Moritz Bunkus | $email =~ s/[^\w\.\-\+=@]//ig;
|
||
my %temp_form = ( %{ $self->form }, myconfig_email => $email );
|
||||
my $template = SL::Template::create(type => 'ShellCommand', form => \%temp_form);
|
||||
my $sendmail = $::lx_office_conf{applications}->{sendmail} || $::lx_office_conf{mail_delivery}->{sendmail} || "sendmail -t";
|
||||
$sendmail = $template->parse_block($sendmail);
|
||||
$self->{sendmail} = IO::File->new("|$sendmail") || die "sendmail($sendmail): $!";
|
||||
dbda14c2 | Moritz Bunkus | $self->{sendmail}->binmode(':utf8');
|
||
5896d8bf | Moritz Bunkus | }
|
||
sub start_mail {
|
||||
}
|
||||
sub print {
|
||||
my $self = shift;
|
||||
$self->{sendmail}->print(@_);
|
||||
}
|
||||
sub send {
|
||||
my ($self) = @_;
|
||||
$self->{sendmail}->close;
|
||||
delete $self->{sendmail};
|
||||
}
|
||||
sub keep_from_header {
|
||||
0;
|
||||
}
|
||||
1;
|