Code for "Bcc" field in PHP e-mail form

Discussion in 'PHP' started by jasonstine, Jul 16, 2009.

  1. #1
    Please help -- this may be easy for you, hard for me:

    Simply want to add code for "Bcc" field in PHP e-mail form so that the form also comes to me (in "bcc").

    Is there also a way NOT TO SHOW the "Bcc" field in the message header so the "To" recipient DOESN'T SEE the message also comes to me?

    Here's the code, please tell me how/where to add the "Bcc" part --
    =====


    <?
    $first_name = $_REQUEST['first_name'] ;
    $last_name = $_REQUEST['last_name'] ;
    $company = $_REQUEST['company'] ;
    $emailaddress = $_REQUEST['email'] ;
    $website = $_REQUEST['website'] ;
    $textfield = $_REQUEST['textfield'] ;
    $telephone = $_REQUEST['telephone'] ;
    $industry = $_REQUEST['industry2'] ;
    $message = $_REQUEST['message'] ;
    $message = "$message\n\n$first_name $last_name\n$company\n$industry\n$website\n\n$name\n$textfield $telephone";mail( "to@domain.com", "Company Interest", $message, "From: $emailaddress" );
    ?>
    <script>
    <!--
    window.location= "thankyou.html"
    //-->
    </script>
    <?php
    exit;?>


    =====
    Thank you very much.
     
    jasonstine, Jul 16, 2009 IP
  2. Dennis M.

    Dennis M. Active Member

    Messages:
    119
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #2
    After

    "From: $emailaddress add the following (within the quotes):

    \r\nbcc: \r\n

    and so on.

    Regards,
    Dennis M.
     
    Dennis M., Jul 16, 2009 IP
  3. Rasputin

    Rasputin Peon

    Messages:
    1,511
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Add it to the 'from' section, separated by \r\n:

    $from = "From: $emailaddress\r\n";
    $from .= "Bcc: \r\n";

    I think that by definition the BCC won't be shown to the first recipient since that is why BCC exists, but I never actually tested it.

    edit: post above says the same, posted while I was writing
     
    Rasputin, Jul 16, 2009 IP
  4. jasonstine

    jasonstine Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Dennis M, Rasputin,

    Thank you very much -- they both worked!

    Now, last question, what's the code for making the fields required in the PHP form (first name, last name, company, e-mail address, Web site, telephone, industry)?

    Once more, appreciate it indeed.

    Cordially, ciao,

    Jason
     
    jasonstine, Jul 23, 2009 IP
  5. Chemo

    Chemo Peon

    Messages:
    146
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Chemo, Jul 23, 2009 IP