misslilbit02
07-29-2005, 02:29 AM
Hi,
I'm tying to send two emails from one form. I have my code below but if there is an easier way please assist. Someone please help.
#!/usr/bin/perl
# parse the form data.
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;
}
#error messages
if ($FORM{'email'} =~ /^$/ ){
&dienice("Please enter a valid email address. Please press your back button to correct.");
}
# where is the mail program?
$mailprog = '/usr/sbin/sendmail';
$recipient = 'nikki_barnard@bellsouth.net';
$from = $FORM{'email'};
open (MAIL, "|$mailprog -t") or &dienice("Can't access $mailprog!\n");
print MAIL "To: $recipient\n";
# Reply-to can be set to the email address of the sender,
# assuming you have actually defined a field in your form
# called 'email'.
print MAIL "From: $from\n";
# print a subject line so you know it's from your form cgi.
print MAIL "Reply-to: $FORM{'email'}\n";
# print out a subject line so you know it's from your form cgi.
# The two \n\n's end the header section of the message.
# anything you print after this point will be part of the
# body of the mail.
print MAIL "Subject: Mailing List\n\n";
# here you're just printing out all the variables and values,
# just like before in the previous script, only the output
# is to the mail message rather than the followup HTML page.
print MAIL <<End1;
Hi,
Please add me to your mailing list.
Thank you
End1
close(MAIL);
open (MAIL, "|$mailprog -t") or &dienice("Can't access $mailprog!\n");
print MAIL "To: nikki_barnard@bellsouth.net";
# Reply-to can be set to the email address of the sender,
# assuming you have actually defined a field in your form
# called 'email'.
print MAIL "From: mailinglist@fearfullymadedesigns.com";
# print a subject line so you know it's from your form cgi.
print MAIL "Reply-to: mailinglist@fearfullymadedesigns.com";
# print out a subject line so you know it's from your form cgi.
# The two \n\n's end the header section of the message.
# anything you print after this point will be part of the
# body of the mail.
print MAIL "Subject: Thanks for joining\n\n";
# here you're just printing out all the variables and values,
# just like before in the previous script, only the output
# is to the mail message rather than the followup HTML page.
print MAIL <<End2;
Dear Viewer,
Thank you for joining our mailing list. We look forward to sending you all of our new designs as we release them.
While we promise not to bombard you with junk email you can look forward to being updated on all of the spectacular things
that Fearfully and Wonderfully Made, Inc. will be doing.
Sincerely,
Janna C. Chinnery
CEO
End2
close(MAIL);
sub dienice {
($errmsg) = @_;
print "<h2>Error</h2>\n";
print "$errmsg<p>\n";
print "</body></html>\n";
exit;
}
print "Location: http://www.fearfullymadedesigns.com/index2.htm#thanks\n\n";
I'm tying to send two emails from one form. I have my code below but if there is an easier way please assist. Someone please help.
#!/usr/bin/perl
# parse the form data.
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;
}
#error messages
if ($FORM{'email'} =~ /^$/ ){
&dienice("Please enter a valid email address. Please press your back button to correct.");
}
# where is the mail program?
$mailprog = '/usr/sbin/sendmail';
$recipient = 'nikki_barnard@bellsouth.net';
$from = $FORM{'email'};
open (MAIL, "|$mailprog -t") or &dienice("Can't access $mailprog!\n");
print MAIL "To: $recipient\n";
# Reply-to can be set to the email address of the sender,
# assuming you have actually defined a field in your form
# called 'email'.
print MAIL "From: $from\n";
# print a subject line so you know it's from your form cgi.
print MAIL "Reply-to: $FORM{'email'}\n";
# print out a subject line so you know it's from your form cgi.
# The two \n\n's end the header section of the message.
# anything you print after this point will be part of the
# body of the mail.
print MAIL "Subject: Mailing List\n\n";
# here you're just printing out all the variables and values,
# just like before in the previous script, only the output
# is to the mail message rather than the followup HTML page.
print MAIL <<End1;
Hi,
Please add me to your mailing list.
Thank you
End1
close(MAIL);
open (MAIL, "|$mailprog -t") or &dienice("Can't access $mailprog!\n");
print MAIL "To: nikki_barnard@bellsouth.net";
# Reply-to can be set to the email address of the sender,
# assuming you have actually defined a field in your form
# called 'email'.
print MAIL "From: mailinglist@fearfullymadedesigns.com";
# print a subject line so you know it's from your form cgi.
print MAIL "Reply-to: mailinglist@fearfullymadedesigns.com";
# print out a subject line so you know it's from your form cgi.
# The two \n\n's end the header section of the message.
# anything you print after this point will be part of the
# body of the mail.
print MAIL "Subject: Thanks for joining\n\n";
# here you're just printing out all the variables and values,
# just like before in the previous script, only the output
# is to the mail message rather than the followup HTML page.
print MAIL <<End2;
Dear Viewer,
Thank you for joining our mailing list. We look forward to sending you all of our new designs as we release them.
While we promise not to bombard you with junk email you can look forward to being updated on all of the spectacular things
that Fearfully and Wonderfully Made, Inc. will be doing.
Sincerely,
Janna C. Chinnery
CEO
End2
close(MAIL);
sub dienice {
($errmsg) = @_;
print "<h2>Error</h2>\n";
print "$errmsg<p>\n";
print "</body></html>\n";
exit;
}
print "Location: http://www.fearfullymadedesigns.com/index2.htm#thanks\n\n";