Ed Hall
07-19-2004, 11:04 AM
Does anyone know of a php script that allows emails to be sent to different email address depending on the topic they select.
What i want to do is have emails sent to my regular addess for comments/work/etc and for link requests or questions have them sent to another email. I'm not to good with php yet and I've only constructed a simple form but I don't know how to do that. So any help would be great :).
Koobi
07-20-2004, 01:21 AM
Well ed, if you could show me your forms PHP code I could show you how to combine it with this:
<?php
$subject = trim(strip_tags($_GET['subject']));
switch($subject)
{
default:
case 1;
$address = 'default@site.com';
break;
case 2:
$address = 'work@site.com';
break;
case 3:
$address = 'other@site.com';
break;
}
//Your mail function goes here
//Make sure first parameter of mail() is $address
/*
Example:
mail($address, 'My subject', 'My message');
*/
?>
Add as many "case" statements as you wish, just keep in mind to add a break after them.
The links should look like this:
My <a href="page.php?subject=1" title="Default email">default</a> email address.
My <a href="page.php?subject=2" title="Work email">work</a> email address.
My <a href="page.php?subject=3" title="Other email">other</a> email address.
The key her is "?subject=NUMBER"
Depending on the number, the corresponding email address defined in the switc/case ststements will be used.
Let me know if you have any problems with this.
Arch Stanton
07-20-2004, 01:28 PM
You could use the php formmail clone and make the to field a select box.
http://www.dtheatre.com/scripts/formmail.php
Ed Hall
07-21-2004, 11:20 AM
that could work as well but I'm sure some people won't pay attention to that.. so I rather just have them select what they are asking for etc have have it sent to a specific email... thanks bane but I got a different script that might work out if it doesn't then I'll let you know so that I can figure out how to add this to my current formmail.
Koobi
07-24-2004, 07:26 AM
Sure thing ed :)
Have fun with PHP :D