I have created the following code so when a user chooses a department (Sales, Billing, Marketing, Finance, etc) and uses the contact form I created, the e-mail is sent to the proper person in the company.
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attention'];
$prefphone = $_POST['phone'];
$contact_pref = $_POST['contact'];
$subject = $_POST['subject'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>
";
$badinput = "<h2>Feedback was NOT submitted</h2>
";
echo $badinput;
die ("Go back! ! ");
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>
";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attention = $attention ;
$subject = $attention;
$notes = stripcslashes($notes);
$message = " $todayis [EST]
Attention: $attn
From: $visitor ($visitormail)
Please contact me by: $contact
Phone Number: $phone
Subject: $subject
Message: $notes
Additional Info : IP = $ip
Browser Info: $httpagent
Referral : $httpref
";
$from = "From: $visitormail
";
switch ($attention) {
case "Residential":
mail("mike@company.com", $subject, $message, $from);
break;
case "Billing":
mail("mike@company.com", $subject, $message, $from);
break;
case "Service":
mail("service@company.com", $subject, $message, $from);
break;
case "Technical":
mail("service@company.com", $subject, $message, $from);
break;
}
?>
When the client receives the email the from: field states the sender's email, which is fine for all departments except the Technical-Support department. This department needs to know the sender's email before hand and thus I need to code it so when technical option is chosen and they receive an email, the address is a default one (i.e. technical@company.com).
Not sure how to do this and if this can be done using the switch/case statement?
I may just be missing something here, but can you not just replace:
case "Technical":
mail("service@company.com", $subject, $message, $from);
break;
with
case "Technical":
mail("service@company.com", $subject, $message, $technical_emailaddress);
break;
within the switch case?