Once again I am having problems and cannot figure out why becuase I wrote this script from another I had, the only differnce is that I am trying to bcc email addresses out of a field in my database called student_email:

<?php
// This script adds a students and all their information into the database so
//admins and teachers can access, update, and change the information as needed

// Address error handing.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);


//Setup the datbase connection
include("../include/config.php");
include("../include/opendb.php");
include("../include/functions.php");


// Execute the query.

$email_title    =   trim($_POST['title']);
$email_text     =   trim($_POST['email_text']);

// Check if the form has been submitted.
if (isset($_POST['submit']))
{
    $problem = FALSE; // No problems so far.

if (empty ($email_title))  //check to see if Title has been entered
    {
	$problem = TRUE;
	echo '<p>You forgot to enter the title of the email, Please hit the back button and fill in the missing information</p>';
    echo "<input type=button value=\"Back\" onClick=\"history.go(-1)\">";
    exit;
    }

if (empty ($email_text))   //check to see if Email Body has been entered
    {
	$problem = TRUE;
	echo '<p>You forgot to enter the email text, Please hit the back button and fill in the missing information</p>';
    echo "<input type=button value=\"Back\" onClick=\"history.go(-1)\">";
    exit;
    }



if (!$problem)  //If there is no problem then we will send a message to all parents
{


    // From
    $mailFrom = 'Little SOS';
    $mailFromName = 'admin@littlesaints.net';
    $mailTo = 'Mike.Simonds@dalsemi.com';
    // Reply address
    $mailReplyTo = $mailFrom;

    // Message subject and contents
    $mailSubject = $email_title;
    $mailMessage = $email_text;
    // Text message charset
    //$mailCharset = "windows-1252"; // must be accurate (e.g. "Windows - 1252" is invalid)

    // Create headres for mail() function
    //$headers  = "Content-type: text/html; charset=$mailCharset\r\n";
    $headers = "From: $mailFromName <$mailFrom>\r\n";
    $headers .= "Reply-To: $mailReplyTo\r\n";
    $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
    $headers .= "X-Priority: 1";

    $query = 'SELECT student_email FROM students';
    // Define mysql info here
    $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

    while ($row = mysql_fetch_object($result))
    {
            echo $row->student_email;
            $email = $row['student_email'];
            echo $headers .= "Bcc: $email\n";
    }

    // Send mail
    mail($mailTo, $mailSubject, $mailMessage, $headers);
}
}
?>

here is the form:

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
                  <p>Email title: <input type="text" name="title" size="40" maxsize="100" /></p>
                  <p>Email Text: <textarea name="email_text" columns="40" rows="5"></textarea></p>
                  <input type="submit" name="submit" value="Send Email To Parents" />
</form>

it sends the email to the $mailTo but not the bcc users

Thanks in advance!

Mike

    I updated the mysql call to and added an echo statement to see if the emails are actually being retrieved:

    $mailFrom = 'Little SOS';
            $mailFromName = 'admin@littlesaints.net';
            $mailTo = 'simonds@sportsrant.com';
            // Reply address
            $mailReplyTo = $mailFrom;
    
        // Message subject and contents
        $mailSubject = $email_title;
        $mailMessage = $email_text;
        // Text message charset
        //$mailCharset = "windows-1252"; // must be accurate (e.g. "Windows - 1252" is invalid)
    
        // Create headres for mail() function
        //$headers  = "Content-type: text/html; charset=$mailCharset\r\n";
        $headers = "From: $mailFromName <$mailFrom>\r\n";
        $headers .= "Reply-To: $mailReplyTo\r\n";
        $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n";
        $headers .= "X-Priority: 1";
    
        $query = 'SELECT student_email FROM students';
        // Define mysql info here
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
    
        while ($row = mysql_fetch_assoc($result))
        {
                $email = $row['student_email'];
                echo "$email<br />";
                $headers .= "Bcc: $email\n";
        }
    
    
    
        // Send mail
        mail($mailTo, $mailSubject, $mailMessage, $headers);

    I did some searches here and it seems from what I have read, my headers are correctly when I am using the Bcc:

      a quick scan of the docs for mail() shows this

      bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )

      additional_headers (optional)

      String to be inserted at the end of the email header.
      
      This is typically used to add extra headers (From, Cc, and Bcc). 

      Multiple extra headers should be separated with a CRLF (\r\n).

      There is also this note:

      Note: If messages are not received, try using a LF (\n) only. Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with RFC 2822.

      So try substituting \r\n for \n and see if it works.

        I tired this and none of the emails are going out!

        If anyone could help me I would be forever grateful.

        This is the last script that needs to be complete prior to going live with this admin area

        if (!$problem)  //If there is no problem then we will send a message to all parents
            {
        
        
            // From
            $mailFrom = 'admin@littlesaints.net';
            $mailFromName = 'Little SOS';
            $mailTo = 'name@email.com';
            // Reply address
            $mailReplyTo = $mailFrom;
        
            // Message subject and contents
            $mailSubject = $email_title;
            $mailMessage = $email_text;
            // Text message charset
            //$mailCharset = "windows-1252"; // must be accurate (e.g. "Windows - 1252" is invalid)
        
            // Create headres for mail() function
            //$headers  = "Content-type: text/html; charset=$mailCharset\r\n";
            $headers = "From: $mailFromName <$mailFrom>\n";
            $headers .= "Reply-To: $mailReplyTo\n";
            $headers .= "X-Mailer: PHP/" . phpversion() . "\n";
            $headers .= "X-Priority: 1";
        
            $query = 'SELECT student_email FROM students';
            // Define mysql info here
            $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        
            $headers .= "Bcc: ";
            while ($row = mysql_fetch_assoc($result))
                    {
                            $email = $row['student_email'];
                            $headers .= $email.",";
                    }
            $headers = substr($headers,0, -1); // strip the last comma off
            $headers .= "\n";
        
        
        
            // Send mail
            mail($mailTo, $mailSubject, $mailMessage, $headers);
        }
        
        

        Thanks,
        Mike

          i commented out the mail() function and echo'd out the following

          echo "$mailTo<br />";
                  echo "$mailSubject<br />";
                  echo "$MailMessage<br />";
                  echo "$headers<br />";

          and this is what I got

          Little Saints & Scholars Site
          name@email.com
          test
          
          From: Little SOS Reply-To: admin@littlesaints.net X-Mailer: PHP/4.4.3 X-Priority: 1Bcc: noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com,noreply@sportsrant.com

          everything seems fine with the headers

          I dont get it

            Write a Reply...