Page 1 of 1

Simple HELP with PHP Mail Code

Posted: Thu Jun 01, 2006 3:50 pm
by dannygoor
Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,
I have a simple question,

Here is the code I am using to send an email via php from flash.

everything is working fine, but I would like to submit this to multiple email addresses,,  instead of the firstemail@mail.com address,

can someone please help,,,    here is the code:

Code: Select all

$sendTo = "firstemail@mail.com" ;  // I would also like to send this to secondemail@mail.com.. how do I code this???

$subject = "Application";
$headers = "From: " . $_POST["vFirstName"] ." ". $_POST["vLastName"] . "<" . $_POST["vEmail"] .">\r\n";
$headers .= "Reply-To: " . $_POST["vEmail"] . "\r\n";
$headers .= "Return-path: " . $_POST["vEmail"];
$message = $_POST["vAll"];
mail($sendTo, $subject, $message, $headers);

Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Re: Simple HELP with PHP Mail Code

Posted: Thu Jun 01, 2006 3:53 pm
by PrObLeM
1st don't forget to put the php tags in your post

Code: Select all

$sendTo = array("firstemail@mail.com", "email2@mail.com", "email3@mail.com") ;  
$n = count($sendTo);
for($i=0;$i<$n;$i++) {
$subject = "Application";
$headers = "From: " . $_POST["vFirstName"] ." ". $_POST["vLastName"] . "<" . $_POST["vEmail"] .">\r\n";
$headers .= "Reply-To: " . $_POST["vEmail"] . "\r\n";
$headers .= "Return-path: " . $_POST["vEmail"];
$message = $_POST["vAll"];
mail($sendTo[$i], $subject, $message, $headers);
}

Posted: Thu Jun 01, 2006 5:03 pm
by Chris Corbyn
How many addresses are you referring to? Using mail() is tiresome when sending to many addresses since it opens a new connection for each message. Classes like PHPMailer and Swift avoid that by using a single connection do all of the work (== faster).