Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Form to Multiple Recipients 1

Status
Not open for further replies.

JMaximus

Programmer
Oct 23, 2004
9
US
I've searched all over and must be a fool.
Just started teaching myself PHP on Friday.

I'd like the message to go to two or three users instead of just one. If I were to include: john@hotmail.com and jane@hotmail.com, how I would include that in the code? Been trying to figure out how a cc: might work or something similiar.

Here is my current code:

<?php
$recipient = 'jamie@fourpeaksplanning.com';

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$spectimereq = $_POST['specifictime'];
$sendtools=($_POST['sendtools'])?"Send planning tools: Yes":"Send planning tools: No";
$mornings=($_POST['mornings'])?"Mornings: Yes":"Mornings: Bad time";
$afternoons=($_POST['afternoons'])?"Afternoons: Yes":"Afternoons: Bad time";
$evenings=($_POST['evenings'])?"Evenings: Yes":"Evenings: Bad time";
$weekdays=($_POST['weekdays'])?"Weekdays: Yes":"Weekdays: Bad time";
$weekends=($_POST['weekends'])?"Weekends: Yes":"Weekends: Bad time";
$comments = $_POST['comments'];

$subject = "Request an appointment: $name";


$body .= 'Sender: '.$name . "\n";
$body .= 'Phone: '.$phone . "\n";
$body .= 'Email: '.$email . "\n\n";
$body .= "$mornings \n";
$body .= "$afternoons \n";
$body .= "$evenings \n";
$body .= "$weekdays \n";
$body .= "$weekends \n";
$body .= 'Specific time requested: '.$spectimereq . "\n\n";
$body .= "$sendtools \n";
$body .= 'Questions and comments: '.$comments . "\n\n";

mail($recipient, $subject, $body);
?>


In advance, thanks for the help!
 
You can include more than one email address in your $recipient variable:
Code:
$recipient = 'email@addr.1,email@addr.2,email@addr.3';
or you can use the 4th parameter to the mail function to provide extra headers:
Code:
$headers = 'From: Your Name <yourname@your.email.addr>'."\n";
$headers .= 'Cc: other@email.addrs'."\n";

mail($recipient,$subject,$body,$headers);

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top