Pikachu2000 - well it works when i used:
<select name='department' id='department'>
<option value='
[email protected]'>Department 1</option>
</select>
But when i tried to add in another email address like:
<select name='department' id='department'>
<option value='
[email protected],
[email protected]'>Department 1</option>
</select>
The email form wouldnt send. I thought by putting in another email address, i could send to another person, but i assume the syntax in the option value is wrong?
PHP Freak - Yes very true on the spamming aspect, it was usuing this method just to get a basic model working. Although i found this out on the web which was reccommended but no luck:
<?php
function SendMail( $email_to ) {
$personalinjuryEmailArray = array( "
[email protected]", "
[email protected]" );
$credithireEmailArray = array( "
[email protected]" );
switch( $_POST['department'] ){
case "1":
foreach ( $personalinjuryEmailArray as $email_to ){
SendMail( $email_to );
}
break;
case "2":
foreach ( $credithireEmailArray as $email_to ){
SendMail( $email_to );
}
break;
}
$email = strip_tags($_POST['email']);
$message = "Title: " . strip_tags($_POST['title']) . "\r\n";
$message .= "Name: " . strip_tags($_POST['name']) . "\r\n";
$message .= "Email Address: " . strip_tags($_POST['email']) . "\r\n";
$message .= "Address: " . strip_tags($_POST['address']) . "\r\n";
$message .= "Telephone: " . strip_tags($_POST['telephone']) . "\r\n";
$message .= "Message: " . strip_tags($_POST['comment']) . "\r\n";
$headers = "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";
$subject = "Website Contact Form Enquiry". $subject;
if(mail($email_to, $subject, $message, $headers)){
echo 'sent';
} else echo 'failed';
}
?>
Is there anyway the first option could work with multiple addresses?
Thanks for the replies though guys