Please can someone tell me why this won't work! I thought at first it must be the location to sendmail, but that didnt work (tried all three different locations possibilities). I then added an error sub to see if the email actually was being sent, but that didn't return anything, so now I am officially stumped! Any ideas you guys? I have never learned how to program the encode stuff, so all of this is new to me
Well, here is the code;
### User variables - you may change things in this section as indicated ###
# Change this to the correct path to Sendmail for your system #
$mailprog="/usr/lib/sendmail";
# Change this to the LITERAL PATH to the files you wish to mail. Do not forget the ending / #
$filelocation="/home/wwwtempl/public_html/templates/purchase/download/";
# Change this to the email address you want mails to be sent FROM and leave \ behind the @ sign#
$adminmail="webmaster\@wwwtemplates.com";
# Change this to the name you want mails to be sent FROM #
$adminname="Webmaster";
# Change this to reflect the subject line you require for your mails #
$subjectline="Your Template from WWWTemplates.com";
# Change this to show the message you want to include (i.e. the body of the email). #
# A new line is entered by using \n e.g. Hi there\n\nThank-you for your interest in blah blah #
# Note that "Dear Name\n\n" has been inserted for you automatically, Name being the name submitted #
# Change this to the URL of the screen you want to display after the user has submitted the form #
#(i.e. a confirmation screen)#
$returnscreen="http://wwwtemplates.com/templates/purchase/safe/confirmed.cgi?do=sent";
# DO NOT alter anything from here on #
read (STDIN,$temp,$ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$temp);
foreach $item(@pairs)
{
($key,$content)=split (/=/,$item);
$content=~tr /+/ /;
$content=~s /%(..)/pack("c",hex($1))/ge;
$fields{$key}=$content;
}
require ("mimetypes.pl");
&sendproduct;
$message = qw~First of all, let me congratulate you on your purchase from our quality selection of templates. We hope you enjoy using your purchase, and it saves you a lot of money from time you would have otherwise spent trying to do something like this! Please find attached a copy of the template you just purchased. ~;
sub sendproduct
{
$file=$filelocation.$fields{'attachment'};
($ext) = $file =~ m,\.([^\.]*)$,;
$ext =~ tr,a-z,A-Z,;
$fext=&mimetype($ext);
my @boundaryv = (0..9, 'A'..'F');
srand(time ^ $$);
for (my $i = 0; $i++ < 24;)
{
$boundary .= $boundaryv[rand(@boundaryv)];
}
open MAIL, "| $mailprog -t" || die &error('$!');
print MAIL "To: $fields{'email'}\n";
print MAIL "From: $adminmail\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Subject: $subjectline\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 "$message";
print MAIL "\n";
print MAIL "--------------$boundary\n";
print MAIL "Content-Type: $fext; name=\"$fields{'attachment'}\"\n";
print MAIL "Content-Transfer-Encoding: base64\n";
print MAIL "Content-Disposition: inline; filename=\"$fields{'attachment'}\"\n\n";
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;
print "Location: $returnscreen\n\n";
exit();
}
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;
}
sub error
{
$error = shift;
print "Content-type: text/html \n\n";
print "$error";
}Thanks to anyone that can help!
Andy
webmaster@ace-installer.com
http://www.ace-installer.com

Well, here is the code;
Code:
#!/usr/bin/perl ### User variables - you may change things in this section as indicated ###
# Change this to the correct path to Sendmail for your system #
$mailprog="/usr/lib/sendmail";
# Change this to the LITERAL PATH to the files you wish to mail. Do not forget the ending / #
$filelocation="/home/wwwtempl/public_html/templates/purchase/download/";
# Change this to the email address you want mails to be sent FROM and leave \ behind the @ sign#
$adminmail="webmaster\@wwwtemplates.com";
# Change this to the name you want mails to be sent FROM #
$adminname="Webmaster";
# Change this to reflect the subject line you require for your mails #
$subjectline="Your Template from WWWTemplates.com";
# Change this to show the message you want to include (i.e. the body of the email). #
# A new line is entered by using \n e.g. Hi there\n\nThank-you for your interest in blah blah #
# Note that "Dear Name\n\n" has been inserted for you automatically, Name being the name submitted #
# Change this to the URL of the screen you want to display after the user has submitted the form #
#(i.e. a confirmation screen)#
$returnscreen="http://wwwtemplates.com/templates/purchase/safe/confirmed.cgi?do=sent";
# DO NOT alter anything from here on #
read (STDIN,$temp,$ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$temp);
foreach $item(@pairs)
{
($key,$content)=split (/=/,$item);
$content=~tr /+/ /;
$content=~s /%(..)/pack("c",hex($1))/ge;
$fields{$key}=$content;
}
require ("mimetypes.pl");
&sendproduct;
$message = qw~First of all, let me congratulate you on your purchase from our quality selection of templates. We hope you enjoy using your purchase, and it saves you a lot of money from time you would have otherwise spent trying to do something like this! Please find attached a copy of the template you just purchased. ~;
sub sendproduct
{
$file=$filelocation.$fields{'attachment'};
($ext) = $file =~ m,\.([^\.]*)$,;
$ext =~ tr,a-z,A-Z,;
$fext=&mimetype($ext);
my @boundaryv = (0..9, 'A'..'F');
srand(time ^ $$);
for (my $i = 0; $i++ < 24;)
{
$boundary .= $boundaryv[rand(@boundaryv)];
}
open MAIL, "| $mailprog -t" || die &error('$!');
print MAIL "To: $fields{'email'}\n";
print MAIL "From: $adminmail\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Subject: $subjectline\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 "$message";
print MAIL "\n";
print MAIL "--------------$boundary\n";
print MAIL "Content-Type: $fext; name=\"$fields{'attachment'}\"\n";
print MAIL "Content-Transfer-Encoding: base64\n";
print MAIL "Content-Disposition: inline; filename=\"$fields{'attachment'}\"\n\n";
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;
print "Location: $returnscreen\n\n";
exit();
}
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;
}
sub error
{
$error = shift;
print "Content-type: text/html \n\n";
print "$error";
}
Andy
webmaster@ace-installer.com
http://www.ace-installer.com