-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail.pl
More file actions
66 lines (54 loc) · 1.63 KB
/
mail.pl
File metadata and controls
66 lines (54 loc) · 1.63 KB
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
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl -w
unless (open(INFILE, "./dump")) {
die ("$!\n");
}
unless (open(OUTFILE, ">dump.html")) {
die ("cannot open output file dump.html\n");
}
$line = <INFILE>;
print OUTFILE ('<html>');
open (OUTFILE, ">>dump.html");
print OUTFILE ('<body>');
print OUTFILE ('<p align=right>');
while ($line ne "") {
print OUTFILE ($line, '<br>');
$line = <INFILE>;
}
print OUTFILE ('</p>');
print OUTFILE ('</body>');
print OUTFILE ('</html>');
use MIME::QuotedPrint;
use MIME::Base64;
use Mail::Sendmail 0.75;
%mail = (
from => 'doron@ashrait.dbs.co.il',
to => 'doron.dollev@dbs.co.il',
subject => 'Test attachment',
);
$boundary = "====" . time() . "====";
$mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\"";
$message = encode_qp( "sending dump.html." );
#Content-Type: text/plain; charset="iso-8859-8"
#$file = $^X; # This is the perl executable
#unless (open(F, "$file")) {
#die ("$!\n");
#}
$file = "dump.html";
open (OUTFILE, "$file") or die "Cannot read $file: $!";
binmode OUTFILE; undef $/;
$mail{body} = encode_base64(<OUTFILE>);
close OUTFILE;
$boundary = '--'.$boundary;
$mail{body} = <<END_OF_BODY;
$boundary
Content-Type: text/html; charset="windows-1255"
Content-Transfer-Encoding: quoted-printable
$message
$boundary
Content-Type: application/octet-stream; name="$file"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="$file"
$mail{body}
$boundary--
END_OF_BODY
sendmail(%mail, Smtp =>'cerberus.dbs.co.il') || sendmail(%mail, Smtp =>'mailsrv03.dbs.co.il') || print "Error: $Mail::Sendmail::error\n";