in reply to CGI recipient Option

I'm not sure I understand what you want, but I believe it's one of these:

1) Emailing works, but you want to change the recipient depending on a checkbox. Add:

$recipient = 'test@test.edu' if ($FORM{'ckusno'});

2) Emailing works, but you want to send the email to two recipients depending on a checkbox. Put the mail stuff in a subroutine and call it twice:

$recipient2 = 'test@test.edu'; sub mail_it { my ($to) = @_; open (MAIL, "|$mailprog $to") || die "Can't open $mailprog!\n"; print MAIL "Reply-to: $FORM{'espr2'} $FORM{'estb'} $FORM{'espr'}\n" +; print MAIL "MIME-Version: 1.0\n"; print MAIL "To: $to\n"; ... print MAIL "</body></html>"; close (MAIL); } mail_it($receipient); mail_it($receipient2) if ($FORM{'ckusno'});

In the future, please specify what it does wrong, not just what you want it to do.

Replies are listed 'Best First'.
Re^2: CGI recipient Option
by quissett (Initiate) on Sep 01, 2004 at 16:22 UTC
    Thanks for your feedback. Does it matter where the #$recipient = 'test@test.edu' if ($FORM{'ckusno'}); goes?
      After the foreach $pair (@pairs) loop (because that's where %FORM is initialized), but before open(MAIL, ...) (because that's where $receipient is used).
        Could you do an if/else? for example:
        $recipient='hdavis@whoi.edu' if($FORM{'ckusno'}); else $recipient='hdavis@whoi.edu';
Re^2: CGI recipient Option
by Anonymous Monk on Sep 01, 2004 at 17:30 UTC
    I can't seem to get this to work. When I leave just the $recipient2 = 'test@test.edu'; at the top as is everything is fine. When I try add changes it does not seem to like this. Thanks Q