PDA

View Full Version : Multiple PHP Form Recipients


Joe051864
02-25-2007, 07:43 PM
Hi, I'm hoping to get some help with a script I'm using that someone here was kind enough to share, it works great but I need it to go to 3 different email addresses, if anyone can help I would really appreciate it. Thanks! Below is the line I need help with, I tried to just stack the 2nd line with the other 2 addresses but no luck.

// Your email address. This is where the form information will be sent.
$emailadd = 'joe@sitewired.net';

davidj
02-25-2007, 07:58 PM
notice the .= on the 2 other vars which concatinates the vars together


$emailadd = 'joe@sitewired.net';
$emailadd .= '; joe@sitewired.net'; // 2nd email address
$emailadd .= '; joe@sitewired.net'; // 3rd email address

Joe051864
02-25-2007, 08:10 PM
Thank you so much!

Joe051864
02-25-2007, 08:28 PM
So I tried this to start and no luck, any thoughts?

// Your email address. This is where the form information will be sent.
$emailadd = 'joe@sitewired.net';
$emailadd .= '; joe_naccarato@hotmail.com';

davidj
02-25-2007, 08:31 PM
post the script

Joe051864
02-25-2007, 08:39 PM
<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'Results from Contact form';
// Your email address. This is where the form information will be sent.
$emailadd = 'joe@sitewired.net';
$emailadd .= 'joe_naccarato@hotmail.com';
// Where to redirect after form is processed.
$url = 'http://www.sitewired.net/index.html';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '1';
// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

davidj
02-25-2007, 09:05 PM
try this

amend/delete your script to include the following


$eol="\r\n";
$emailadd = 'joe@sitewired.net';
$emailadd .= 'joe_naccarato@hotmail.com';

$headers .= 'From: MyName<'.$fromaddress.'>'.$eol;
$headers .= 'Reply-To: MyName<'.$fromaddress.'>'.$eol;
$headers .= 'Return-Path: MyName<'.$fromaddress.'>'.$eol;

mail($emailadd, $emailsubject, $msg, $headers);

Joe051864
02-25-2007, 09:18 PM
Thanks David, I'll give that a try. I really appreciate your help on this.

Joe051864
02-25-2007, 09:55 PM
I tried this:


<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'Results from Contact form';
// Your email address. This is where the form information will be sent.
$eol="\r\n";
$emailadd = 'joe@sitewired.net';
$emailadd .= 'joe_naccarato@hotmail.com';

$headers .= 'From: MyName<'.$fromaddress.'>'.$eol;
$headers .= 'Reply-To: MyName<'.$fromaddress.'>'.$eol;
$headers .= 'Return-Path: MyName<'.$fromaddress.'>'.$eol;

mail($emailadd, $emailsubject, $msg, $headers);
// Where to redirect after form is processed.

and it didnt work, then I removed the 2nd email address and it worked.

scratches head, um...any more ideas?

davidj
02-25-2007, 09:57 PM
your second var should be like this

$emailadd .= '; joe_naccarato@hotmail.com';

notice the semicolon before the email address

Joe051864
02-25-2007, 10:03 PM
Tried this and still no good, is this what you meant below?

// Your email address. This is where the form information will be sent.
$eol="\r\n";
$emailadd = 'joe@sitewired.net';
$emailadd .= '; joe_naccarato@hotmail.com';

$headers .= 'From: MyName<'.$fromaddress.'>'.$eol;
$headers .= 'Reply-To: MyName<'.$fromaddress.'>'.$eol;
$headers .= 'Return-Path: MyName<'.$fromaddress.'>'.$eol;

mail($emailadd, $emailsubject, $msg, $headers);
// Where to redirect after form is processed.

davidj
02-25-2007, 10:42 PM
try this

instead of a semi colon delimiter use a comma (see first var)

$emailadd = 'joe@sitewired.net ,'; //<< comma here
$emailadd .= 'joe_naccarato@hotmail.com';