use MIME::Base64 qw(encode_base64);my $sendmail = '/usr/sbin/sendmail';
my $to = 'linux@domain1.ru';
my $from = 'my@domain2.ru';
my $attachment = '/path_to/file.tar.gz';
my $buf;
my $subject = MIME::Base64::encode_base64('Здесь размещаем тему письма.');
$subject =~ s/\n//g;
my $data;
$data = MIME::Base64::encode_base64("<p>Здесь<br>Можно разместить текст сообщения.<br></p>");
my $boundary = 'simple boundary';
open(MAIL, "| $sendmail -t -oi") or die("$!");
print MAIL <<EOF;
To: $email_to
From: $email_from
Subject: =?UTF-8?B?$subject?=
Content-Type: multipart/mixed; boundary="$boundary"
This is a multi-part message in MIME format.
--$boundary
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: base64
$data
--$boundary
Content-Type: application/octet-stream; name="$attachment"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="$attachment"
EOF
open(FILE, "<$attachment") or die "$!";
while (read(FILE, $buf, 60*57)) { print MAIL encode_base64($buf); }
close FILE;
close MAIL;
URL:
Обсуждается: https://www.opennet.ru/tips/info/929.shtml