Gossamer Forum
Home : General : Perl Programming :

Re: Email attachments

Quote Reply
Re: Email attachments In reply to
Here's how I do it...

Code:
my @boundaryv = (0..9, 'A'..'F');
srand(time ^ $$);
for (my $i = 0; $i++ < 24;) {
$boundary .= $boundaryv[rand(@boundaryv)];
}
Code:
open(MAIL,"|$mail");
print MAIL "To: $email\n";
print MAIL "From: $me\n";
print MAIL "Subject: $subject\n";
print MAIL "Content-Type: multipart/mixed; boundary=\"------------$boundary\"\n";
print MAIL "\n";
print MAIL "This is a multi-part message in MIME format.\n";
print MAIL "--------------$boundary\n";
print MAIL "Content-Type: text/plain; charset=us-ascii\n";
print MAIL "Content-Transfer-Encoding: 7bit\n\n";
print MAIL "Hello\n";
print MAIL "\n";
print MAIL "--------------$boundary\n";
print MAIL "Content-Type: application/octet-stream; name=\"$file\"\n";
print MAIL "Content-Transfer-Encoding: base64\n";
print MAIL "Content-Disposition: inline; filename=\"$file\"\n\n";
Code:
my $buf;
$/=0;
open INPUT, "$file";
binmode INPUT if ($^O eq 'NT' or $^O eq 'MSWin32');
while(read(INPUT, $buf, 60*57)) {
print MAIL &encode_base64($buf);
}
close INPUT;
print MAIL "\n--------------$boundary--\n";
print MAIL "\n";
close MAIL;

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Subject Author Views Date
Thread Email attachments Endor 4859 Apr 16, 2001, 1:39 PM
Thread Re: Email attachments
Paul 4740 Apr 16, 2001, 2:21 PM
Thread Re: Email attachments
Endor 4692 May 27, 2001, 12:16 PM
Thread Re: Email attachments
Paul 4689 May 27, 2001, 1:14 PM
Thread Re: Email attachments
Endor 4672 May 27, 2001, 4:55 PM
Thread Re: Email attachments
Paul 4684 May 27, 2001, 5:00 PM
Thread Re: Email attachments
Chef 4638 Jun 3, 2001, 7:23 AM
Post Re: Email attachments
Paul 4644 Jun 3, 2001, 7:58 AM