-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail.pm
More file actions
executable file
·40 lines (32 loc) · 797 Bytes
/
Copy pathmail.pm
File metadata and controls
executable file
·40 lines (32 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package mail;
use strict;
use warnings;
use Carp 'croak';
sub new{
my ($class,$from,$to,$subject) = @_;
my $self = {
'from' => $from,
'to' => $to,
'subject' => $subject,
'body' => "",
'cmd' => "sendmail -t"
};
bless $self,$class;
return $self;
}
sub addtext {
my ($self, $txt) = @_;
$self->{'body'} .= $txt;
}
sub sendmail {
my ($self) = @_;
open(my $process,"| ".$self->{'cmd'}) || croak("Couldn't start sendmail process");
print $process "From: ".$self->{'from'}."\n";
print $process "To: ".$self->{'to'}."\n";
print $process "Subject: ".$self->{'subject'}."\n";
print $process "\n";
print $process $self->{'body'};
print $process "\n";
close($process);
}
1;