PDA

View Full Version : PHP to send form results to multiple email addresses


SimplyMorocco.com
04-26-2007, 08:12 AM
I am using the very useful script 'Using Dreamweaver and PHP to send form results in an email' by Ramandeep. ( http://www.dreamweaverclub.com/dreamweaver-php-form.php). I would like to modify it so that when a form is sent, it can be sent to two or more email addresses. Any help would be great

Paws
04-26-2007, 09:59 AM
Add this after the ?> tag; YES at the end of the script.
Add as many as you need...
<?php
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
?>

If that does not help, let us know.:mrgreen:

davidj
04-26-2007, 11:08 AM
paws

i dont understand how that would work?

/////

Post the script and i will check it out

Paws
04-26-2007, 11:41 AM
<?php
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
?>
Well that code is already set to send the mail, so you add another like this:

<?php
mail(mail@domain.com, subject, text, 'From: '.mail@domain.com.'');
?>

And another email will be sent.

Paws
04-26-2007, 12:30 PM
My bad add this just after the first mail script like this:


<?php
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');

//Extra emails to send
mail(mail@domain.com, subject, text, 'From: '.mail@domain.com.'');
?>

If it does not work, let us know...:mrgreen:

fwr1000
04-26-2007, 12:36 PM
I too was facing this problem and rather that change the script, I set up a new e mail address with my web hosting account, ("webmail_reply@mydomain.com" for example) and used that as the PHP "mail to". Then, on the host I set this new address to auto forward to multiple addresses. If your web host allows you to set up e mail address for your domain through their control panel, this is a quick way. Also, if the the intended receipent address ever changes or you need to add or delte someone, all you have to do is change it at the web host and don't have to mess with the script.

Fred

davidj
04-26-2007, 01:48 PM
ah ic now

your adding 2 mail() functions or as many as you need

i get you now.

the better way would be to do this...


<?php
$emailadd = name@domain.com, ; //<< note the comma
$emailadd .= name2@domain.com, ; //<< note the comma
$emailadd .= name3@domain.com;

mail($emailadd, $subject, $text, 'From: '.$emailadd.'');//<<just have the one function

?>