headers in mail(); function not exicuting

Discussion in 'PHP' started by wajid_pk, Sep 11, 2009.

  1. #1
    i wrote a small script in PHP to send mail
    
    $headers = 'To: mail.com
    $headers = 'From: from name mail
    $headers = 'Cc: inc cc
    
    $headers .= 'Bcc: inc bcc (this header is not working)
    
    Code (markup):
    script sends to and cc but do not to bcc
     
    wajid_pk, Sep 11, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Err, that code won't run.. you're not even ending the php strings with ';

    Anyway, if you have a problem, it's best if you look at http://www.php.net/mail (in this case). The below code is straight from that page. Not hard to find, right?

    
    // Additional headers
    $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
    $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
    $headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
    $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
    PHP:
    So you should use the \r\n after each header.
     
    premiumscripts, Sep 11, 2009 IP
  3. wajid_pk

    wajid_pk Peon

    Messages:
    334
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes i am using exactly this script and copied from the site you mentioned
    i test it with
    *[*email]email[*/email*]and "\n"; double quotes and single quotes 
    Code (markup):
    including MIME 1.0 and many additional headers every thing works only BCC header the script do not send to mail mentioned in BCC

    i am using example#4 script from php.net
     
    wajid_pk, Sep 11, 2009 IP
  4. Marc Fraser

    Marc Fraser Peon

    Messages:
    283
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Post the code you've got now...
     
    Marc Fraser, Sep 12, 2009 IP
  5. wajid_pk

    wajid_pk Peon

    Messages:
    334
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    
    <?php
    // multiple recipients
    $to  = 'aidan@example.com' . ', '; // note the comma
    
    // subject
    $subject = $HTTP_POST_VARS['subject'];
    
    // message
    $message = '
    <html>
    <head>
      <title>Birthday Reminders for August</title>
    </head>
    <body>
      <p>Here are the birthdays upcoming in August!</p>
      <table>
        <tr>
          <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
        </tr>
        <tr>
          <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
        </tr>
        <tr>
          <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
        </tr>
      </table>
    </body>
    </html>
    ';
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
    $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
    $headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
    $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
    // Mail it
    //mail($to, $subject, $message, $headers);
    //remove "//" before mail
    
    PHP:



    also if i want to send more then one Bcc i need make new header for the next email address??
     
    wajid_pk, Sep 12, 2009 IP