Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cgi attachment in sendmail

Status
Not open for further replies.
Joined
Nov 5, 2004
Messages
3
Location
US
Hello,
I know this isn't hard, but I just can't figure it out. I have a form where a user can attach a file, but can't figure out how to add the code to the cgi sendmail portion.
Any help?
Thanks!
 
What we have here is a lack of meaningful information ...

You can upload the file to the server, but can't e-mail it is this correct?

Can you post some code you we can have some context please

--Paul



Nancy Griffith - songstress extraordinaire,
and composer of the snipers anthem "From a distance ...
 
There is no lack of meaninful information, just lack of knowledege on how to do it. I didn't know it had to be uploaded to a server before being sent via email.
The code is a very simple script that sends me an email with the customer information. I want to add the ability for the customer to be able to send a file.
Here is the code I have:

#!/usr/bin/perl
require "cgi-lib.pl";
&ReadParse;
$mailprog = '/usr/sbin/sendmail';
print &PrintHeader;
unless (-e $mailprog)
{
print <<"PrintTag";
<HTML><BODY>
<H3>Cannot find $mailprog.</H3>
<P>There is a typo in the mail program path.</P>
</BODY></HTML>
PrintTag
exit(0);
}

#create confirmation web page
print <<"PrintTag";
<HTML><HEAD>
<TITLE>Thanks for responding!</TITLE>
</HEAD>
<BODY BGCOLOR="white" TEXT="black">
<H2>Thank You!</H2>
<P>Thanks for filling out our form.</P>
<P>Check your e-mail for a message from us.</P>
<a href="</body></html>
PrintTag


open (MAIL, "|$mailprog -t") ||die "Can't open mail program\n";
#customer mail is being sent to
print MAIL "To: $in{'email'}\n";
#who mail is coming from and
#replying to
print MAIL "Reply-To: $in{'empmail'}\n";
print MAIL "From: $in{'empmail'}\n";
#subject
print MAIL "Subject: Your advertising request.\n\n";
#body
print MAIL << "PrintTag";
Dear $in{'custname'}:

Thank you for writing. This e-mail
confirms that we have received your
request for advertising information. We will
contact you soon!

Sincerely yours,
Daffodil Valley Times
Staff
PrintTag
close (MAIL);

#to the company
open (MAIL, "|$mailprog -t") ||die "can't open mail program\n";
print MAIL "To: $in{'empmail'}\n";
print MAIL "Reply-To: $in{'email'}\n";
print MAIL "From: $in{'email'}\n";
print MAIL "Subject: Advertising.\n\n";
print MAIL << "PrintTag";
$in{'custname'}
$in{'address'}
$in{'city'} $in{'state'} $in{'zip'}
$in{'comments'}
PrintTag
close (MAIL);

Thanks!
Tig
 
Tig,

1) Look at the FAQ section ( also (perl)) here for information on uploading files to the server, remember to housekeep otherwise you'll be out of space, and wondering why things don't work
2) Look up Net::SMTP as a much more portable way of sending mail with attachments, on
HTH
--Paul

BTW
I know this isn't hard, but I just can't figure it out. I have a form where a user can attach a file, but can't figure out how to add the code to the cgi sendmail portion.
is a definitive lack of information, what form, what cgi sendmail

Nancy Griffith - songstress extraordinaire,
and composer of the snipers anthem "From a distance ...
 
Okay, it was a lack of information and knowledge... :)
I'll check that out, thanks!
Tig
 
no worries, that's what we're here 4
--Paul

Nancy Griffith - songstress extraordinaire,
and composer of the snipers anthem "From a distance ...
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top