Mail Form Issue: Recipient dependent on multi-select list

I’m pretty much a noob at the PHP stuff. I’m trying to use a form to send an email. However, I want the email to go to different addresses based on different values chosen in a drop down box.

Here’s the mailing code I’m working with but can’t make it happen:

//Sending Email recipient based on partner value
$the_header = "From: $submitted_byn"
  . "Reply-To: $submitted_byn";
$the_subject = "Tax Department Assignment";
$the_message = "Submitted By: $submitted_byn"
. "Client Name: $client_namen"
. "Client Number: $client_numbern"
. "Partner: $partnern"
. "Date Assigned: $date_assignedn"
. "Due Date: $due_daten"
. "Detailed Description: $detailed_descriptionn";

if($partner = "Bill") {
$the_mail_to = "[email protected]";

elseif($partner = "Ernie") {
$the_mail_to = "[email protected]";

elseif($partner = "Joe") {
$the_mail_to = "[email protected]";

@mail($the_email_to, $the_subject ,$the_message ,$the_header ) ;

When I submit the form I do not get any errors, but I don’t get any emails either.

Can someone help me out with this? Thanks

You are assigning values to variables $the_mail_to and you are using $the_email_to in the mail() function. Either change the variable in the mail to $the_mail_to or add the ‘e’ on the $the_mail_to. Also it might be helpful in the future to get rid of the last elseif and just have else unless you are thinking about adding another test parameter.

Sponsor our Newsletter | Privacy Policy | Terms of Service