On Wed, 20 Mar 2002 13:07:56 +0100, [EMAIL PROTECTED] (Anthony) wrote:

>is it possible to have a perl script sending e-mail with attachment without
>using MIME::Lite since most host don't have MIME::Lite.?
>

You could try this  script
#########################################################
#!/usr/bin/perl
use warnings;
use strict;
use MIME::Base64;

my $SENDFILE = 'myfile';
my $FROMUSER = 'username';
my $FROMEMAIL = '[EMAIL PROTECTED]';
my $TOUSER = 'myrecipient';
my $TOEMAIL = '[EMAIL PROTECTED]';

open(F_MAIL,"|/usr/sbin/sendmail -t");

my $boundary = "----------90125";
print F_MAIL <<END_OF_MAIL;
Precedence: list
From: $FROMUSER <$FROMEMAIL>
To: $TOUSER <$TOEMAIL>
MIME-Version: 1.0
Subject: File attachment test
Content-Type: multipart/mixed;
    boundary=\"$boundary\"
    
This is a multi-part message in MIME format.
        
--$boundary
Content-Type: text/plain;
    charset=\"iso-8859-1\"
                                        
Here is the body of the message.  A file attachment is also provided below.
                
--$boundary
Content-Type: application/octet-stream;
name=\"z\"
Content-Transfer-Encoding: Base64
Content-Disposition: attachment;
filename=\"z\"

END_OF_MAIL

#open(F_SEND,$SENDFILE) || &Error("Cannot open sendfile for MIME encoding");
open(F_SEND,$SENDFILE) || die ("Cannot open sendfile for MIME encoding");
while (read(F_SEND,my $buf, 60 * 57 ) ) {
print F_MAIL encode_base64($buf);
}
close(F_SEND);

print F_MAIL <<END_OF_MAIL;
--$boundary--
END_OF_MAIL
close(F_MAIL);



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to