Contact Form : Multiple Emails

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
-caffeinerush-
Forum Newbie
Posts: 2
Joined: Thu Sep 14, 2006 10:32 pm

Contact Form : Multiple Emails

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It may be easier, safer, and/or better to use a mailing library such as Swift or phpMailer.
-caffeinerush-
Forum Newbie
Posts: 2
Joined: Thu Sep 14, 2006 10:32 pm

Post by -caffeinerush- »

Thanks, but I ended up just adding a second line. I'll keep those in mind for critical apps though.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post 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
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

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