Attaching a file to email - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Attaching a file to email

zenozeno Posts: 2Member
Please help. I am trying to attach a file to a genererated email.

Here is the relevant HTML form code: and . And I have pasted the relevant CGI code below.

The problems is that the email works fine until the user actually attempts to attach a file. In other words, if the HTML form is filled-out without attaching a file ($WordDoc) then the email is generated and all is well. But if the user, in addition, attaches a file then the CGI script fails.

the CGI code:

open MAIL, "$mailprogram";

print MAIL "To: $recip
print MAIL "From: $from_addr
print MAIL "Subject: $subject

print MAIL "Content-Type: multipart/mixed; boundary=boundarystring

print MAIL "--boundarystring
print MAIL "Content-type: text/html
print MAIL $message;

print MAIL "--boundarystring
print MAIL "Content-Type: application/msword
print MAIL "Content-Transfer-Encoding: base64
print MAIL "Content-Disposition: attachment; filename='TheWordDoc.Doc'";
print MAIL $FORM{$WordDoc};

print MAIL "--boundarystring--";

close MAIL;

Thank you. Peter.


Sign In or Register to comment.