PDA

View Full Version : How can I make the message be sent to 2 emails?



artweb99
10 Jun 2011, 12:38 PM
Hi guys,
I'm having a little problem I need help with. I created a form in HTML and I did the PHP code for the submission button. My question is, how can I make the message be sent to 2 different emails instead of one only.

Here is my PHP code:

<?php
/*subject and email varibales*/

$emailsubject = 'via Bo-sacs website';
$webmaster = 'artweb99@gmail.com';

/*gathering data variables*/

$nameField = $_POST['name'];
$emailField = $_POST['email'];
$commentField = $_POST['comment'];



$body = <<<EOD
<br><hr><br>
Name : $name <br>
Email : $email <br>
Comment : $comment<br>

EOD;


$headers = "From: $email\r\n";
$headers = "Content-type: text/html\r\n";
$success = mail($webmaster,$emailsubject,$body,$headers);



/*Results randered as HTML */


$theResults = <<<EOD


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>merci</title>
</head>

<body>
<p>Votre message a été envoyer, nous vous répondrons dans les plus bref délais

</p>
</body>
</html>
EOD;
echo "$theResults";

?>


Thank you

Dominic
10 Jun 2011, 07:47 PM
If I understand correctly, all you have to do is replace your $webmaster bit with



$webmaster = 'artweb99@gmail.com, another@email.com';


If you take a look at http://php.net/manual/en/function.mail.php it explains it in further detail.