To: From: Subject: =?UTF-8?B??= Message-ID: <> Date: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------" Content-Language: ru This is a multi-part message in MIME format. -------------- Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit -- signature -------------- Content-Type: ; name="" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="" ---------------- #### my $email_params = { to => $email, from => 'robot@domain.ru', subject => encode_base64('Subject',''), text => 'Mail text', boundary => encode_base64($email,''), date => email_date(time);, msgid => encode_base64($email.$date,'').'@domain.ru', }; foreach my $d (sort keys %{$email_docs} ) { push @{ $email_params->{attachments}}, { FILEBASE64 => encode_base64($d->pdf), # binary FILENAME => $d->filename_pdf, FILETYPE => "application/pdf", } } my $tpl = new HTML::Template(filename => $template); $tpl->param($email_params); open(my $MAIL, "|/usr/local/bin/sudo /usr/sbin/sendmail -t"); print $MAIL $tpl->output; close ($MAIL);