shaman (18-03-2001 22:14):
Light Elf (18-03-2001 20:38):
А получается принимаемы файл сохранить на диске?
Получается вообще отправить письмо с текстом без вложения?
И сохранять получается, и письмо без вложения отправляется???
Может кто другим путем это делает, так подскажите.
Сенкс
Я делаю так:
use CGI;
use MIME::Base64 qw(encode_base64);
$cgi = new CGI;
# attachment: file body
if ( defined $cgi->param(\'file\') && $cgi->param(\'file\') ne \'\') {
    # flag
    $attachment = 1;
    # get and decode file content
    $attFName = $cgi->param(\'file\');
    $tmpFName = $cgi->tmpFileName($attFName);
    ($shortFName) = ($attFName =~ /.*[\\/\\\\](.*?)$/);
    unless ( open FILE, "<$tmpFName") {
        $attBody = \'cannot open and decode file\';
    } else {
        binmode FILE;
        $attBody = \'\';
        while (read(FILE, $buf, 60*57)) {
                $attBody .= encode_base64($buf);
        }
        close FILE;
    }
}
# Mail the message
unless ( open ( TMP, "| /usr/sbin/sendmail -f \\"$from\\" -oi $to" ) ) {
    print "Content-type: text/html
";
    print "Error: Cannont send e-mail!"
    exit 0 ;
}
# print common header of the message
print TMP "From: $from
";
print TMP "To: $to
";
print TMP "Subject:  $subject
";
# print headers for attachment (if exists)
if ($attachment) {
    print TMP "MIME-Version: 1.0
";
    print TMP "Content-Type: multipart/mixed; boundary=\\"nextpart\\"
";
    print TMP "
";
    print TMP "--nextpart
";
}
# print end of header
print TMP "
";
# print message body
print TMP $message;
# print attachment
if ($attachment) {
        print TMP "--nextpart
";
        print TMP "Content-Type: application/octet-stream; name=\\"$shortFName\\"
";
        print TMP "Content-Transfer-Encoding: base64
";
        print TMP "Content-Disposition: attachment; filename=\\"$shortFName\\"
";
        print TMP "
";
        print TMP $attBody;
        print TMP "--nextpart--
";
}
close TMP ;
print "Content-type: text/html
";
print "The message was sent
";