Gurus, I've been having this problem in various permutations throughout my Perl life. For this particular function, I set $confirm_counter to 1. Then I use a foreach loop to send email to multiple recipients. Within the foreach loop, I increment $confirm_counter by using $confirm_counter++. I then use the value of $confirm_counter as a test for an if conditional. If the counter is one, then a confirmation email will be sent to the person who submitted the form. If not, the confirmation email will be skipped. This is to prevent any user from receiving more than one confirmation email. However, it seems that $confirm_counter is not being incremented and the user will receive as many as 7 email confirmations. Any ideas? I'm enclosing the code in question below. sub send_mail { #Camilo experiments here my $confirm_counter = "1"; @selected_recipients = ($Form{recipient0}, $Form{recipient1}, $Form{recipient2}, $Form{recipient3}, $Form{recipient4}, $Form{recipient5}, $Form{recipient6}); my $recipient_counter = ""; foreach $recipient_counter(@selected_recipients){ @mailPrefix = split (/@/,$recipient_alias{$recipient_counter}); if ($mailPrefix[0]){ if (($Form{joinPreview} eq "yes") or ($Form{newsletterSend} eq "yes")){ $subject = "Sneak Preview Form Inquiry"; $skip = "no"; } else { $subject = "WWW Legacy Form Inquiry"; $skip = "yes"; } my ($date, $Field_Order) = @_; my $dashes = '-' x 75; my $realname = $Config{realname}; if (defined $realname) { $realname = ' (' . cleanup_realname($realname) . ')'; } else { $realname = $Config{realname} = ''; }
if ($secure) { $subject = substr($subject, 0, 256); } my $email = $Config{email}; unless (defined $email and check_email($email)) { $email = 'nobody'; } if ("$Config{recipient}$email$realname$subject" =~ /\r|\n/) { die 'multiline variable in mail header, unsafe to continue'; } my $xheader = ''; if ( $secure and defined (my $addr = remote_addr()) ) { $addr =~ /^\[?([\d\.]+)\]?$/ or die "bad remote addr [$addr]"; $xheader = "X-HTTP-Client: [$1]\n" . "X-Generated-By: NMS FormMail.pl v$VERSION\n"; } if ( $confirm_counter = "1"){ if ( $send_confirmation_mail ) { open_sendmail_pipe(\*CMAIL, $mailprog); print CMAIL $xheader, "To: $email$realname\n$confirmation_text$confirm_counter"; close CMAIL; } } ++$confirm_counter; open_sendmail_pipe(\*MAIL, $mailprog); print MAIL $xheader, <<EOMAIL; To: $recipient_alias{$recipient_counter} From: $email$realname Subject: $subject Below is the result of your feedback form. It was submitted by $Config{realname} (${\( $Config{email}||'' )}) on $date $dashes $subject EOMAIL if ($Config{print_config}) { foreach (@{$Config{print_config}}) { print MAIL "$_: $Config{$_}\n\n" if $Config{$_}; } } foreach (@$Field_Order) { my $val = (defined $Form{$_} ? $Form{$_} : ''); if ($Config{'print_blank_fields'} || $val !~ /^\s*$/) { print MAIL "$_: $val\n\n"; } } print MAIL "$dashes\n\n"; foreach (@{$Config{env_report}}) { print MAIL "$_: ", strip_nonprintable($ENV{$_}), "\n" if $ENV{$_}; } close (MAIL) || die "close mailprog: \$?=$?,\$!=$!"; } &set_counter($skip, $mailPrefix[0]); } } #!/usr/local/bin/perl print <<' EOF' Camilo Gonzalez Web Developer Taylor Johnson Associates [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> www.taylorjohnson.com <http://www.taylorjohnson.com/> EOF