•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 427,223 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,272 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 719 | Replies: 3
![]() |
•
•
Join Date: Sep 2005
Location: St. Louis
Posts: 145
Reputation:
Rep Power: 4
Solved Threads: 0
I'm trying to get an email generated when a form is processed. This is my first stab at such. It's not working for some reason. When I comment out the lines concerning the email generation, it works fine. The problem apparently lies somewhere in that section of the code, but I'm not sure just what the issue is.
#!/usr/bin/perl
#trialSubscription.cgi
print "Content-type: text/html\n\n";
use CGI qw(:standard);
use Mail::Sendmail;
use strict;
#var declarations
my ($firstName, $lastName, $email, $street, $city, $state, $zip, $msg, %mail);
#var values
$firstName = param('firstName');
$lastName = param('lastName');
$email = param('email');
$street = param('street');
$city = param('city');
$state = param('state');
$zip = param('zip');
#create message to email
$msg = "$firstName $lastName would like to subscribe to a free 6 month trial of SGN Scoops. His/her email address is $email. \n";
$msg = $msg . "The physical address is $street in $city, $state $zip.";
#create page
print <<endHtml;
<html>
<head>
<title>Thank you for subscribing</title>
<body>
<p> </p>
<p> </p>
<p> </p>
<p align="center" /><font size="4" face="Arial">Thank you for subscribing, $firstName.<br />
Click <a href="index.html">here</a> to return to the SGN Scoops main page.</font></p>
</body>
</html>
endHtml
#send email
$mail{To} = 'kahaj@yahoo.com';
$mail{From} = $email;
$mail{Subject} = 'Trial Subscription Request';
$mail{Smtp} = 'mail.sgnscoops.com';
$mail{Message} = $msg;
sendmail(%mail); Be what you is, don't be what you ain't.
Cause if you ain't what you is, you is what you ain't!
Cause if you ain't what you is, you is what you ain't!
•
•
Join Date: Sep 2005
Location: St. Louis
Posts: 145
Reputation:
Rep Power: 4
Solved Threads: 0
In my previous post, I used an example from a text book. I've scoured the web and found various reccomendations on how to accomplish my goal. I've tried the following only to end up with a 500 error still.
Any tips with this would be fantastic.
Any tips with this would be fantastic.#!/usr/bin/perl
#trialSubscription.cgi
use CGI qw(:standard);
use Mail::Sendmail;
use strict;
#var declarations
my ($firstName, $lastName, $email, $street, $city, $state, $zip, $msg, %mail);
#var values
$firstName = param('firstName');
$lastName = param('lastName');
$email = param('email');
$street = param('street');
$city = param('city');
$state = param('state');
$zip = param('zip');
#send email
open (MESSAGE,"| /usr/sbin/sendmail -t");
print MESSAGE "To: kahaj\@yahoo.com\n";
print MESSAGE "From: sgnscoops.com", reader\n";
print MESSAGE "Subject: Trial Subscription Request \n\n";
print MESSAGE "$firstName $lastName\n\n";
print MESSAGE "$email\n\n";
print MESSAGE "$street\n";
print MESSAGE "$city, $state $zip\n\n";
close MESSAGE;
#create page
print <<endHtml;
<html>
<head>
<title>Thank you for subscribing</title>
<body>
<p> </p>
<p> </p>
<p> </p>
<p align="center" /><font size="4" face="Arial">Thank you for subscribing to our free trial offer, $firstName.<br />
We hope that you enjoy the all-new SGN Scoops!<br />
Click <a href="index.html">here</a> to return to the SGN Scoops main page.</font></p>
</body>
</html>
endHtml Be what you is, don't be what you ain't.
Cause if you ain't what you is, you is what you ain't!
Cause if you ain't what you is, you is what you ain't!
replace these lines:
replace with:
"header" is a function of the CGI modules ":standard" functions and will print the http header which is required before printing anything else to the browser. I could have sworn I already told you that on another forum but maybe I am confused.
#create page print <<endHtml;
replace with:
#create page print header; print <<endHtml;
"header" is a function of the CGI modules ":standard" functions and will print the http header which is required before printing anything else to the browser. I could have sworn I already told you that on another forum but maybe I am confused.
Last edited by KevinADC : Jul 10th, 2008 at 7:58 pm.
•
•
Join Date: Sep 2005
Location: St. Louis
Posts: 145
Reputation:
Rep Power: 4
Solved Threads: 0
If you did, I certainly don't recall it, but I won't swear that you didn't. At any rate, I changed that and it still says the same thing. My server's error log does say this:
"Premature end of script headers: /home/.../public_html/cgi-bin/trialSubscription.cgi"
I'm doing some research to see what could cause this, but I'm finding a lot of different tips. I'm going to start trying them one by one to see how it goes (or how it doesn't go).
"Premature end of script headers: /home/.../public_html/cgi-bin/trialSubscription.cgi"
I'm doing some research to see what could cause this, but I'm finding a lot of different tips. I'm going to start trying them one by one to see how it goes (or how it doesn't go).
Be what you is, don't be what you ain't.
Cause if you ain't what you is, you is what you ain't!
Cause if you ain't what you is, you is what you ain't!
![]() |
•
•
•
•
•
•
•
•
DaniWeb Perl Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- php script for dropdown to fetch DB list and then Tables (PHP)
- TAX processing system suggestion... (C++)
- Processing array values (PHP)
- dynamically update pages (HTML and CSS)
- Processing Checkbox Information From A Form (JavaScript / DHTML / AJAX)
- problem in sending mail form web application (ASP.NET)
- VB6 application form freezes (Visual Basic 4 / 5 / 6)
- Setting the command buttons Forecolor (Visual Basic 4 / 5 / 6)
- Help with printing mulitple documents in js...! (HTML and CSS)
Other Threads in the Perl Forum
- Previous Thread: Crypt::Blowfish / Crypt::CBC
- Next Thread: problem


Linear Mode