[ back to toc ]

???

Date: 2002/01/05 13:35

Q:
Hi PETER,

I WISH U HAPPY NEW YEAR.

HERE IS MY PROBLEM. HOW CAN I SEND A MAIL WITH AN ATTACHMENT. I'M
USING PERL 5.0 AND UNIX MECHINE. THIS IS THE CODE FOR SENDING A MAIL, YOU
PLEASE GIVE ME A CODE FOR SENDING ATTACHMETS ALSO.

#! /usr/bin/perl use CGI qw(:all);
print "Content-type: text/html","\n\n";
print "<html>
<head>
<title>APRLP</title>
</head>";
print "<body bgcolor=#FFFFFF>";

$name=param('Name');
$company=param('Company');
$designation=param('Designation');
$address=param('Address');
$city=param('City');
$country=param('Country');
$phone=param('Phone');
$subject = "ENQUIRY\n";
$toEmail="info\@aplive.org";

$b = "Sir/Madam,

The following data was entered in the Form\n\n";

$mailInfo = " Name : ".$name."\n".
" Company : ".$company."\n".
" Designation: ".$designation."\n".
" Address : ".$address."\n".
" City : ".$city."\n".
" Country : ".$country."\n".
" Phone : ".$phone."\n".
"Thank you.";

$b=$b.$mailInfo."\n";

if(open(EMAIL,"|/usr/lib/sendmail -t") ){
print EMAIL "To: $toEmail\n";
#print EMAIL "cc: $updaterid1\n";
print EMAIL "Error-To: $Email\n";
print EMAIL "Reply-To: $Email\n";
#print EMAIL "Return-Path: $updaterid\n";
print EMAIL "From: $Email\n";
print EMAIL "Subject: $subject\n";
#print EMAIL "MIME-Version: 1.0\n";
#print EMAIL "Content-Type: text/plain\n";
print EMAIL "$b";
print " <center>Thanks for Submitting your form1, we will get in touch
with you shortly.</center><br><br>";
print "<center><a href=\"http://www.MYPAGE.org/index.html\">Go Back to
Home</a></center>";
close EMAIL;

}
else
{
print "sorry";
}

A:
If you want to send an attachment then you have to format your mail
miltupart mime data. For the exact notation please consult the RFC that
defines SMTP and the one defining MIME.

I have actually no experience in this field, so I can not give more
detailed help on this. Those documents would be the ones that I would
consult if ever I face the issue.

The other possibility that there should be some SMTP module for Perl that
delivers the feature and formats the mail for you.

Regards,
Peter

[ back to toc ]