PDA

View Full Version : sendmail not processing completely


charbort
01-30-2003, 03:12 PM
I have the following code that doesn't work completely. It processes the form and redirects after submission but I don't recieve any emails.

Unfortunately my eyes are going nuts I've been looking at it so long. Any ideas?

Thanks in advance,
Charbort




# ORGINAL CODE TO SEND ONE EMAIL
# Send E-Mail
# &send_mail;
# END ORIGINAL CODE

# MULTIPLE MAIL SENDING FROM CHECKBOXES

if ($Form{subject1} eq "true"){ #if checkbox "subject1" is checked
$Config{subject} = "Subscribe Wildlife"; #set message subject
&send_mail; #and send the message to the subscription manager
}
if ($Form{subject2} eq "true"){ #if checkbox "subject2" is checked
$Config{subject} = "Subscribe Fishing"; #set message subject
&send_mail; #and send the message to the subscription manager
}
if ($Form{subject3} eq "true"){ #if checkbox "subject3 is checked
$Config{subject} = "Subscribe Heritage"; #set message subject
&send_mail; #and send the message to the subscription manager
}
if ($Form{subject4} eq "true"){ #if checkbox "subject4" is checked
$Config{subject} = "Subscribe Nongame"; #set message subject
&send_mail; #and send the message to the subscription manager
}
if ($Form{subject5} eq "true"){ #if checkbox "subject5" is checked
$Config{subject} = "Subscribe Urban"; #set message subject
&send_mail; #and send the message to the subscription manager
}

# END OF MULTIPLE MAIL SENDING FROM CHECKBOXES




sub send_mail {
# Localize variables used in this subroutine. #
local($print_config,$key,$sort_order,$sorted_field,$env_report);

# Open The Mail Program
open(MAIL,"|$mailprog");

print MAIL "To: $Config{'recipient'}\n";
print MAIL "From: $Config{'email'} ($Config{'realname'})\n";

# Check for Message Subject
if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n" }
else { print MAIL "Subject: Subscription page\n\n" }

print MAIL "The following information was submitted on the Sign up for AZGFD Email page. It was submitted by\n";
print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
print MAIL "-" x 75 . "\n\n";

if (@Print_Config) {
foreach $print_config (@Print_Config) {
if ($Config{$print_config}) {
print MAIL "$print_config: $Config{$print_config}\n\n";
}
}
}

Philip M
01-30-2003, 07:26 PM
Is the problem

# &send_mail;

the # character rems the line out so the sub is never called.

charbort
01-30-2003, 08:37 PM
I tried removing # and it processes, but it seems to not be getting the subjects set from the checkboxes because the email (to myself for testing) had the else subject line "Subscription page".

# Check for Message Subject
if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n" }
else { print MAIL "Subject: Subscription page\n\n" }


I was under the assumption that all the form inputs not in the Config would goto the %form automatically. Is that correct or do I need to define it?

----- form code -----

<form style="margin-bottom:0;" method="POST" action="/cgi-bin/subscribe.cgi" onsubmit="return checkbox_checker(this)" name="checkbox_form">

<input name="subject1" type="checkbox" value="Subscribe Wildlife">
<input name='subject2' type='checkbox' value='Subscribe Fishing'>
<input name='subject3' type='checkbox' value='Subscribe Heritage'>
<input name='subject4' type='checkbox' value='Subscribe Nongame'>
<input name='subject5' type='checkbox' value='Subscribe Urban'>

Thanks,
Charbort[B]Subscription page Subscription page

Philip M
01-31-2003, 06:58 PM
I think that the construction

if ($Form{subject1} eq "true")

means that the value is the literal word 'true', not the Boolean true. eq is the string comparison operator.

Try simply:-

if ($Form{subject1}) .......

charbort
01-31-2003, 07:08 PM
Ahhh, yes because I haven't specified any input as subject yet the %form and Config don't see it.

Thanks, I'll give it a try.