Revision 24ab7ec0
Von Moritz Bunkus vor etwa 9 Jahren hinzugefügt
SL/Mailer/Sendmail.pm | ||
---|---|---|
10 | 10 |
|
11 | 11 |
use Rose::Object::MakeMethods::Generic |
12 | 12 |
( |
13 |
scalar => [ qw(myconfig mailer form) ] |
|
13 |
scalar => [ qw(myconfig mailer form status extended_status) ]
|
|
14 | 14 |
); |
15 | 15 |
|
16 | 16 |
sub init { |
17 | 17 |
my ($self) = @_; |
18 | 18 |
|
19 |
Rose::Object::init(@_); |
|
19 |
Rose::Object::init( |
|
20 |
@_, |
|
21 |
status => 'failed', |
|
22 |
extended_status => 'no send attempt made', |
|
23 |
); |
|
20 | 24 |
|
21 | 25 |
my $email = Encode::encode('utf-8', $self->myconfig->{email}); |
22 | 26 |
$email =~ s/[^\w\.\-\+=@]//ig; |
... | ... | |
26 | 30 |
my $sendmail = $::lx_office_conf{applications}->{sendmail} || $::lx_office_conf{mail_delivery}->{sendmail} || "sendmail -t"; |
27 | 31 |
$sendmail = $template->parse_block($sendmail); |
28 | 32 |
|
29 |
$self->{sendmail} = IO::File->new("|$sendmail") || die "sendmail($sendmail): $!";
|
|
33 |
$self->{sendmail} = IO::File->new("|$sendmail") or do { $self->extended_status("sendmail($sendmail): $!"); die $self->extended_status; };
|
|
30 | 34 |
$self->{sendmail}->binmode(':utf8'); |
31 | 35 |
} |
32 | 36 |
|
... | ... | |
36 | 40 |
sub print { |
37 | 41 |
my $self = shift; |
38 | 42 |
|
39 |
$self->{sendmail}->print(@_); |
|
43 |
$self->{sendmail}->print(@_) or do { $self->extended_status("sendmail: $!"); die $self->extended_status; };
|
|
40 | 44 |
} |
41 | 45 |
|
42 | 46 |
sub send { |
43 | 47 |
my ($self) = @_; |
44 |
$self->{sendmail}->close; |
|
48 |
|
|
49 |
$self->{sendmail}->close or do { $self->extended_status("sendmail: $!"); die $self->extended_status; }; |
|
50 |
|
|
51 |
$self->status('ok'); |
|
52 |
$self->extended_status(''); |
|
53 |
|
|
45 | 54 |
delete $self->{sendmail}; |
46 | 55 |
} |
47 | 56 |
|
Auch abrufbar als: Unified diff
E-Mail-Journal: verschickte E-Mails speichern