CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2007
    Location
    Italia
    Posts
    45

    mail() function and Bcc field

    I need to send the same email in plain text format to several users.
    I can do that, but there is a problem: those users who use a gmail account (and only them) can see the email addresses in the Bcc field.

    Is there a way to hide those addresses to gmail users?

    This is my code
    PHP Code:
    $i=0;
    while(
    $row mysql_fetch_array($addresses)) {
        if(
    $i==0//first addres into the field To:
            
    $receiver $row['email'];
        else 
    //others into Bcc
            
    $bcc .= $row['email'].", ";
        
    $i++;
    }

    $header .= "MIME-Version: 1.0\r\n";
    $header .= "Content-type: text; charset=iso-8859-1\r\n";
    $header .= "From: My site <[email protected]> \r\n";
    $header .= "Bcc: ".$bcc."\r\n";
    $object "email's object";
    $message "email's text.\r\n";
    mail($receiver$object$message$header); 

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: mail() function and Bcc field

    I altered you script a tiny bit (acquiring e-mail addresses). None of my Gmail accounts saw any other BCC headers. However, I did make one other change. I added a declaration of the variable instance $bcc. You have not declared it anywhere. So, when you are appending to it, it doesn't exists the first time. Same happens with $header.

    PHP Code:
    $bcc '';
    $i 0;
    while(
    $row mysql_fetch_array($addresses)) {
      if (
    $i == 0) {$receiver $row['email'];}
      else {
    $bcc .= $row['email'].", ";}
      
    $i++;
    }

    $headers "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text; charset=iso-8859-1\r\n";
    $headers .= "From: My site <[email protected]> \r\n";
    $headers .= "Bcc: ".$bcc."\r\n";
    $subject "email's subject";
    $message "email's text.\r\n";
    mail($receiver$subject$message$headers); 
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured