Hi,
I am writing a script that email a file from a website however the file is on the Senders Computer and is being sent in for checking.
Please can someone help me??? Please
Below is my code that should handle the message
My Problem is I get a message but the attachment is not there, I but 2 Denug lines in the code one when the attachment routine is called (It Prints) and the second after the file is attached (It does not print?)
You can test the script at the file will email to the address you put in, so you can see my problem.
Sorry for the long message, but please help.
Kind Regards, Paul Benn
**** Never Giveup, keep trying, the answer is out there!!! ****
I am writing a script that email a file from a website however the file is on the Senders Computer and is being sent in for checking.
Please can someone help me??? Please
Below is my code that should handle the message
My Problem is I get a message but the attachment is not there, I but 2 Denug lines in the code one when the attachment routine is called (It Prints) and the second after the file is attached (It does not print?)
You can test the script at the file will email to the address you put in, so you can see my problem.
Sorry for the long message, but please help.
Code:
sub send_message
{
## Send File to poster Start
my @boundaryv = (0..9, 'A'..'F');
srand(time ^ $$);
for (my $i = 0; $i++ < 24;)
{
$boundary .= $boundaryv[rand(@boundaryv)];
}
open MAIL, "|$mailprog -t";
print MAIL "To: $tomail ($toname)\n";
print MAIL "From: $email_address ($your_name)\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Subject: $fileinfo\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/html; charset=us-ascii\n";
print MAIL "Content-Transfer-Encoding: 7bit\n\n";
print MAIL "<b>Dear $toname,\n\n</b><br><br>\n";
print MAIL "<br>Here is the file<br><br>File Attached: <b>$filename</b><br><br>\n";
print MAIL "<br><br>\n";
#print MAIL "--------------$boundary\n";
## Attach the file
&attach_files;
close INPUT;
print MAIL "<br><b>End Attach file</b><br>\n";
print MAIL "\n--------------$boundary--\n";
print MAIL "\n";
close MAIL;
$status = "Sent";
&okay_html;
}
sub attach_files {
$file=$attachment;
($ext) = $file =~ m,\.([^\.]*)$,;
$ext =~ tr,a-z,A-Z,;
$fext=&mimetype($ext);
print MAIL "<br><b>Start Attach file</b><br>\n";
print MAIL "--------------$boundary\n";
print MAIL "Content-Type: $fext; name=\"$filename\"\n";
print MAIL "Content-Transfer-Encoding: base64\n";
print MAIL "Content-Disposition: attachment; filename=\"$filename\"\n\n";
&buf_type;
print MAIL "Content-Type: text/html; charset=us-ascii\n";
print MAIL "Content-Transfer-Encoding: 7bit\n\n";
print MAIL "File: $filename Attached";
print MAIL "--------------$boundary--\n";
#print MAIL "--------------$boundary\n";
print MAIL "<br><b>End Attach file</b><br>\n";
}
sub buf_type {
my $buf2;
$/=0;
open INPUT, "$file";
binmode INPUT if ($^O eq 'NT' or $^O eq 'MSWin32');
while(read(INPUT, $buf2, 60*57))
{
print MAIL &encode_base64($buf2);
}
}
sub encode_base64 #($)
{
my ($res, $eol, $padding) = ("", "\n", undef);
while (($_[0] =~ /(.{1,45})/gs))
{
$res .= substr(pack('u', $1), 1);
chop $res;
}
$res =~ tr#` -_#AA-Za-z0-9+/#; # ` help emacs
$padding = (3 - length($_[0]) % 3) % 3; # fix padding at the end
$res =~ s#.{$padding}$#'=' x $padding#e if $padding; # pad eoedv data with ='s
$res =~ s#(.{1,76})#$1$eol#g if (length $eol); # lines of at least 76 characters
return $res;
}
**** Never Giveup, keep trying, the answer is out there!!! ****