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

Perl Form Processing (send in html format)

Status
Not open for further replies.

airski

Programmer
Nov 25, 2002
8
US
I have created a simple perl program that will take a users input from a form and email that input to me. The only problem is that i would like for it to be sent to my email in html format. I have created this program to send the input to an email address in text format and print a "thank you for filling out this form" to the browser in html format.

This is how I send to my email.

open (MAIL "|$mail_prog -t");
print MAIL "Contact Name:\n";
print MAIL "".$contactname."\n\n" ;
close (MAIL)

I know this is redundant because i have to create a new print statement for every single field i want to be printed to the email. How can i send this in html format? I would like to be able to send the field value to email only if the user has entered something. The way it is now it prints the "Contact Name" header everytime even if there is no input from the user.

I would appreciate any help!

Thanks,

Travis
 
open (MAIL "|$mail_prog -t");

# prints the line only if
# $contactname contains atleast
# one non-blank character.
# (i.e. it is something.)
print MAIL "Contact Name:\n$contactname\n\n" if $contactname =~ /[^\s]/;

close (MAIL)

I'm not real experienced w/ the e-mail script hacking, so I don't know how to indicate to the client that it's HTML. I would imagine that it's a matter of setting content-type headers like a CGI script.

--jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top