Ben bir kullanıcı bir bölümü (Satış, Fatura, Pazarlama, Finans, vb) seçer ve yaratılan iletişim formunu kullandığında bu nedenle, e-posta şirketi doğru kişiye gönderilen aşağıdaki kodu oluşturduk.
<?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>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attention = $attention ;
$subject = $attention;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Attention: $attn \n
From: $visitor ($visitormail)\n
Please contact me by: $contact \n
Phone Number: $phone \n
Subject: $subject \n
Message: $notes \n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $visitormail\r\n";
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;
}
?>
Teknik Destek departmanı hariç tüm bölümler için gayet alan devletlerin gönderenin e-posta: İstemci gelen e-posta aldığında. Bu bölüm elden önce gönderenin e-posta bilmesi gerekir ve böylece adres varsayılan bir (yani technical@company.com), ben teknik seçeneği seçildiğinde yüzden kod gerekir ve bir e-posta alacaksınız.
Bu switch / case deyimi kullanılarak yapılabilir, bunun nasıl yapılacağını ve eğer emin değil misiniz?