# Form mail help

**URL:** https://forum.kirupa.com/t/form-mail-help/72504
**Category:** Uncategorized
**Created:** [December 6, 2004, 3:33pm UTC](https://forum.kirupa.com/t/form-mail-help/72504 "2004-12-06T15:33:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kev](https://avatars.discourse-cdn.com/v4/letter/k/e9bcb4/32.png) [@kev](https://forum.kirupa.com/u/kev)
#### Post date: [December 6, 2004, 3:33pm UTC](https://forum.kirupa.com/t/form-mail-help/72504/1 "2004-12-06T15:33:57Z")

</div>

Hi all i got a simple form mail.pl script, the script works fine from a form we have on a site, it send the persons details to us via email (as it should)

But I want to also send them a thankyou email as well, but cannot get it to work?

Here is the form mail.pl (cut down alot to save space):

$recipient = ‘me@mycompany.com’;

#$email = $FORM{‘email’};

$homepage = ‘[http://www.homepage.com](http://www.homepage.com)’;

$mailprog = ‘/usr/lib/sendmail’;

print "Content-type: text/html

";

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("C", hex($1))/eg;

$FORM{$name} = $value;

```

}

unless($FORM{‘name’}&&$FORM{‘serial’}&&$FORM{‘email’}  
&&$FORM{‘tel’}) {  
&blank\_response;

}

open (MAIL, “|$mailprog $recipient”) || die "Can’t open $mailprog!  
";  
print MAIL "Reply-to: $FORM{‘name’} ($FORM{‘email’})  
";  
print MAIL "Subject: FAQ request password

";  
print MAIL "$FORM{‘name’} ($FORM{‘company’}) Has request a password for FAQ section of our website  
";  
print MAIL "------------------------------------------------------------  
";  
print MAIL "  
";  
print MAIL "Name: $FORM{‘name’}  
";  
print MAIL "Company: $FORM{‘company’}  
";  
print MAIL "Machine serial number: $FORM{‘serial’}  
";  
print MAIL "Email address: $FORM{‘email’}  
";  
print MAIL "Telephone number: $FORM{‘tel’}

## "; print MAIL "------------------------------------------------------------ "; print MAIL "The vistitor commented: "; print MAIL " "; print MAIL “$FORM{‘problem’}”; print MAIL "

";  
print MAIL "Server protocol: $ENV{‘SERVER\_PROTOCOL’}  
";  
print MAIL "Remote IP address: $ENV{‘REMOTE\_ADDR’}  
";  
close (MAIL);

open (MAIL, “|$mailprog $email”) || die "Can’t open $mailprog!  
";  
print MAIL "Subject: thankyou for your enquiry

";  
close (MAIL);

# Make the person feel good for writing to us

print “\<Body\>\<H1\>Thank you\</H1\>”;  
print “your password will be sent to you ASAP\<P\>”;  
print “Return to our \<A HREF=”$homepage"\>home page\</A\>.\<P\>";

# ------------------------------------------------------------

sub blank\_response  
{  
print “\<Body\>\<H1\>Error!\</H1\>”;  
print “You do not appear to have entered one of the required fields\*. \<P\>”;  
print “return to our \<A HREF=”$back"\>form\</A\>, - and fill in all the fields thank you.\<P\>";  
exit;  
}

As you can see i have tried to use their email from the form to send the email, but it does not work?

any ideas?
