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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending E-mail to the client 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to send confirmation back to the client after they have completed a form.Its not my server, i don't knnow if theres already a program to d o it...
How do i do it myself? from a perl script??
Please Help
Siber-d
 
Hi,
this is the script i use, hope this is what you need.
just type the message into the completewriting bit, fill in your email address and it should work.
Code:
#!/usr/bin/perl

# Enter the location of sendmail.  
$mailprogram = "/usr/sbin/sendmail -t";


@required = ('email','name','country');


$youremail = "somebody\@your_address.co.uk.";

$emailmessage = <<'COMPLETEWRITING';
Thank you for your enquiry.
I will answer your query as fully and as soon as possible.

Mike
your company

COMPLETEWRITING
# Put the posted data into variables

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
        ($name, $value) = split(/=/, $pair);
        $value =~ tr/+/ /;
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
        $FORM{$name} = $value;
}

# Check for all required fields

foreach $check(@required) {
        unless ($FORM{$check}) {
                print &quot;Content-type: text/html\n\n&quot;;
                print &quot;<html><head><title>Missing Information</title></head>\n&quot;;
                print &quot;<body><h1>Missing Information</h1><br>\n&quot;;
                print &quot;I'm sorry, but it would appear that you've forgotten to\n&quot;;
                print &quot;fill out the $check field.  Please click\n&quot;;
                print &quot;back and try again.\n&quot;;
                print &quot;</body></html>\n&quot;;
                exit;
        }
}

# Check the senders email

if ($FORM{'email'}) {
        unless ($FORM{'email'} =~ /\w+@\w+.\w+/) {
                print &quot;Content-type: text/html\n\n&quot;;
                print &quot;<html><head><title>Bad E-mail</title></head>\n&quot;;
                print &quot;<body><h1>Bad E-mail</h1><br>The e-mail address that you've\n&quot;;
                print &quot;entered, $FORM{'email'}, is invalid.  Please click back and\n&quot;;
                print &quot;try again.\n&quot;;
                exit;
        }
}

open (MAIL,&quot;|$mailprogram&quot;);
print MAIL &quot;To: $youremail\n&quot;;
print MAIL &quot;From: $FORM{'email'}\n&quot;;
print MAIL &quot;Subject: $FORM{'subject'}\n&quot;;
print MAIL &quot;Hello.  The following information has been submitted:\n\n&quot;;
foreach $pair (@pairs) {
        ($name, $value) = split(/=/, $pair);
        $value =~ tr/+/ /;
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
        unless ($name eq &quot;response&quot; || $name eq &quot;email&quot; || $name eq &quot;subject&quot;) { 
                print MAIL &quot;$name: $value\n&quot;;
        }
}
close MAIL;

open (MAIL, &quot;|$mailprogram&quot;) || &cgidie (&quot;Can't open $mailprog!\n&quot;);
        print MAIL &quot;To: $FORM{'email'}\n&quot;;
        print MAIL &quot;From: $youremail\n&quot;;
        print MAIL &quot;Subject: $FORM{'subject'} -- Autoresponse\n&quot;;
        print MAIL &quot;$emailmessage\n\n&quot;;        
        close MAIL;


print &quot;Content-type: text/html\n\n&quot;;
print &quot;<html><head><title>Thank you!</title></head>\n&quot;;
print &quot;<body><h1>Thank you!</h1><br>Thanks for your input! \n&quot;;
        print &quot;You should receive an autoresponse shortly.<p>\n&quot;;

print &quot;Please click back.\n&quot;;

regards

terry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top