Simple HELP with PHP Mail Code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dannygoor
Forum Newbie
Posts: 1
Joined: Thu Jun 01, 2006 3:44 pm

Simple HELP with PHP Mail Code

Post 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]
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Re: Simple HELP with PHP Mail Code

Post 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);
}
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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).
Post Reply