1,105,402 Community Members

Adding another bcc reciever

Member Avatar
nyancat
Newbie Poster
1 post since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello,
I want to add another receiver to this contact form, he has to be bcc, and not shown as receiver but still receiving the message from the contact form:

<?php
  		if(isset($_POST['submit'])) {
          error_reporting(E_NOTICE);
          function valid_email($str)
          {
          return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
		     }
          if($_POST['name']!='' && $_POST['email']!='' && valid_email($_POST['email'])==TRUE && strlen($_POST['comment'])>1)
          {
              //$to = preg_replace("([\r\n])", "", $_POST['receiver']);
			  $to = preg_replace("([\r\n])", "", hexstr($_POST['receiver']));
			  $from = preg_replace("([\r\n])", "", $_POST['email']);
			  $subject = "Website contact message from ".$_POST['name'];
              $message = $_POST['comment'];
			  
			  $match = "/(bcc:|cc:|content\-type:)/i";
				if (preg_match($match, $to) ||
					preg_match($match, $from) ||
					preg_match($match, $message)) {
				  die("Header injection detected.");
				}
              $headers = "From: ".$from." . " \r\n";
   			  $headers .= "Reply-to: ".$from."\r\n";
             
        if(mail($to, $subject, $message, $headers))
              {
                  echo 1; //SUCCESS
              }
              else {
                  echo 2; //FAILURE - server failure
              }
          }
          else {
       	  echo 3; //FAILURE - not valid email

          }
		  }else{
			 die("Direct access not allowed!");
		   }
		   
		    function hexstr($hexstr) {
				  $hexstr = str_replace(' ', '', $hexstr);
				  $hexstr = str_replace('\x', '', $hexstr);
				  $retstr = pack('H*', $hexstr);
				  return $retstr;
				}

      ?>

The contact form is template for wp, it takes the receiving email from the theme options.
Thanks!

In the admin where you put the receiving email is this code:

<tr valign="top">
			<th scope="row"><label for="contact_email">Email Address for Contact Form</label></th>
			<td>
				<input name="contact_email" type="text" id="contact_email" value="<?php echo get_option('webfolio_contact_email'); ?>" class="regular-text" />
			</td>
		</tr>
Member Avatar
pritaeas
mod_pritaeas
11,315 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

See the manual, example #4.

Question Answered as of 2 Years Ago by pritaeas
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: