Add bcc to mailform.php |
Add bcc to mailform.php |
Pluribus |
May 8 2013, 07:35 AM
Post
#1
|
Member Group: Members Posts: 81 Joined: 6-February 09 Member No.: 7,737 |
Hi
I am using a premade mailform.php script (below). I need to add a bcc to one of the email addresses - line 18 $emailaddress[2] = "email2@domain.com";. The bcc should point to email4@domain.com. Is this possible? Can anyone help or point me in the right direction? Thanks Ian CODE <?php $dontsendemail = 0; $possiblespam = FALSE; $strlenmessage = ""; $email = $_REQUEST['email']; $message = $_REQUEST['message']; $phone = $_REQUEST['phone']; $name = $_REQUEST['name']; $subject = "Website Contact Form Submission"; $emailaddress = array(); /* NOTE: Although your email addresses are visible here in this code, the person contacting you will never see these email addresses. Your email addresses will remain on your server, and they will not be sent from your server to the person contacting you. They will also remain invisible to spam bots. Your email addresses are also never stored on any of our servers. You can choose to delete or not delete this note when you publish this page. It will not change the functionality of the contact form. */ $emailaddress[1] = "email1@domain.com"; $emailaddress[2] = "email2@domain.com"; $emailaddress[3] = "email3@domain.com"; $contactnameindex = $_REQUEST['emailaddress']; if ($contactnameindex == 0 || !isset($_REQUEST['emailaddress'])) die ("You did not choose a recipient. Please hit your browser back button and try again."); else $emailaddress = $emailaddress[$contactnameindex]; function checkemail($field) { // checks proper syntax if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $field)) { die("Improper email address detected. Please hit your browser back button and try again."); return 1; } } function spamcheck($field) { if(eregi("to:",$field) || eregi("cc:",$field) || eregi("\r",$field) || eregi("\n",$field) || eregi("%0A",$field)){ $possiblespam = TRUE; }else $possiblespam = FALSE; if ($possiblespam) { die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again."); return 1; } } function strlencheck($field,$minlength,$whichfieldresponse) { if (strlen($field) < $minlength){ die($whichfieldresponse); return 1; } } if ($dontsendemail == 0) $dontsendemail = checkemail($email); if ($dontsendemail == 0) $dontsendemail = spamcheck($email); if ($dontsendemail == 0) $dontsendemail = spamcheck($subject); if ($dontsendemail == 0) $dontsendemail = strlencheck($email,10,"The email address field is too short. Please hit your browser back button and check your entry.<br />"); if ($dontsendemail == 0) $dontsendemail = strlencheck($message,10,"The message field is too short. Please hit your browser back button and check your entry.<br />"); if ($dontsendemail == 0) $dontsendemail = strlencheck($emailaddress,8,"You have not selected a recipient of your message. Please hit your browser back button and check your entry.<br />"); if ($dontsendemail == 0) {mail($emailaddress,"Subject: $subject",$message,"From: $email" ); include "emailsent.html";} ?> |
Christian J |
May 8 2013, 08:26 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
For sending an ordinary copy (not a Bcc) you might append the second address here:
CODE $emailaddress[2] = "email2@domain.com, email4@domain.com"; If it has to be a Bcc (does the form user and/or owner of the email2@domain.com address approve of that?) you have to check if $emailaddress[2] is selected, and if so insert email4@domain.com in a Bcc header in the mail function. See also http://php.net/manual/en/function.mail.php |
Pluribus |
May 8 2013, 09:10 AM
Post
#3
|
Member Group: Members Posts: 81 Joined: 6-February 09 Member No.: 7,737 |
For sending an ordinary copy (not a Bcc) you might append the second address here: CODE $emailaddress[2] = "email2@domain.com, email4@domain.com"; If it has to be a Bcc (does the form user and/or owner of the email2@domain.com address approve of that?) you have to check if $emailaddress[2] is selected, and if so insert email4@domain.com in a Bcc header in the mail function. See also http://php.net/manual/en/function.mail.php Thanks Christian, you are a great help as always. The client specifically requested the Bcc to make sure one of the staff is doing their job properly, but the email2@domain.com user wont have any idea... I appreciate your help! |
Lo-Fi Version | Time is now: 25th April 2024 - 11:35 AM |