Page 1 of 1

Contact Form : Multiple Emails

Posted: Thu Sep 14, 2006 10:41 pm
by -caffeinerush-
Hi, I picked up a PHP contact form a little while ago (I'm inept at PHP btw) and am wondering how I would mod it to send the info to multiple email addresses.

Code: Select all

<?php
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
echo $badinput;

$todayis = date("l, F j, Y, g:i a,T") ;

$subject = $visitor;

$notes = stripcslashes($notes);

$message = " $todayis \n
Name: $visitor \n
Company: $visitorcompany \n
Phone Number: $phone \n
Message: $notes \n
From: $visitor ($visitormail)\n
----------------------------------------------------- \n
Technical information:
IP = $ip \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";


mail("email@account.com", $subject, $message, $from);

?>


<span class="text">Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />
You will recieve a reply shortly.<br>
Your Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?></span>
I tried checking out the synax and adding another email by the && operator, but that didn't seem to work. (I only need to send to 2 emails)
I've also searched here and google, but haven't found anything but mass mailers.

Thanks in advance.

Posted: Fri Sep 15, 2006 12:28 pm
by feyd
It may be easier, safer, and/or better to use a mailing library such as Swift or phpMailer.

Posted: Fri Sep 15, 2006 6:08 pm
by -caffeinerush-
Thanks, but I ended up just adding a second line. I'll keep those in mind for critical apps though.

Posted: Fri Sep 15, 2006 7:00 pm
by nickvd
I'd read up on email header injection... as from what i can see, your contact form can (and likely will) be used by SPAM BOTS

Posted: Fri Sep 15, 2006 8:18 pm
by neophyte
Yes they will. I have a contact form over at http://webgeneius.com/?mod=contact

It get hits periodically with bots trying to exploit the form. I get 5 emails each one trying to inject headers. Fortunately, I don't believe they have successfully exploited it. I just get emails with header lines in it.