-
Notifications
You must be signed in to change notification settings - Fork 0
/
cronBuffer.pl
55 lines (49 loc) · 1.39 KB
/
cronBuffer.pl
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl
if ($#ARGV > 0) {
if ($#ARGV == 1) {
$to = $ARGV[0];
$subject = $ARGV[1];
$subject =~ s/_/ /g;
}
}
while (<STDIN>) {
$content .= $_;
}
$from = 'AWS <server@'.`hostname`;
chomp($from);
$from.=">";
sub sendmail {
($msg,$from,$to,$subject,$bcc,$filepath,$filename) = @_;
use MIME::Lite;
#mime::Lite->send("sendmail", "/usr/sbin/sendmail -t -oi -oem");
$yoursmtpserver = "/usr/lib/sendmail -t";
#$subject .= "to=$to";
if ($bcc ne "") {
$mailer = MIME::Lite->new(From=>$from,
To=>$to,
Subject=>$subject,
Type=>'multipart/mixed');
} else {
$mailer = MIME::Lite->new(From=>$from,
To=>$to,
Subject=>$subject,
Type=>'multipart/mixed');
}
$mailer->attach( Type=>'text/plain',
Data=> $msg);
if ($filepath ne "") {
(undef,$type) = split(/\./,$filename);
$mailer->attach(Type=>"application/$type",
Path=>"$filepath",
Filename=>"$filename",
Dispostion=>'attachment');
}
if (! $mailer->send('sendmail', $yoursmtpserver)) {
return(0);
} else {
return(1);
}
}
if ($content ne '') {
sendmail("$content",$from,$to, $subject);
}