Ciao a tutti, ho un problema con l'invio delle email.

L'invio email funziona in questo modo:

1) gli indirizzi sono divisi in gruppi, quindi per poter visualizzare gli indirizzi da poter scegliere, prima di tutto devo scegliere il gruppo (es.: media, simpatizzanti,...)

2) una volta scelto il gruppo scelgo a chi voglio inviare l'email

L'invio funziona se:

Nel campo destinatario inserisco un indirizzo e nel campo bcc ne inserisco uno o più.

Funziona anche se nel campo destinatario non inserisco nulla ma nel campo bcc si

Il problema è quando metto nel campo cc un indirizzo o più indirizzi. Mi dice che l'email è stato inviata ma non ricevo niente agli indirizzi bcc.

ESEMPIO:

Destinatario: indirizzo1
cc: indirizzo2
bcc: indirizzo3, indirizzo4

Il destinatario e cc ricevono mentre i bcc no...praticamente gli indirizzi bcc vengono incorporati all'interno del testo dell'email.


MI SAPETE DARE UNA MANO????? Funziona tutto bene a parte questo particolare se utilizzo il campo cc.

Vi posto i 2 file .php che utilizzo

Codice PHP:

<?php
    
//include('connect.php');
    
include('fckeditor/fckeditor.php');
    
session_start();
?>

<html>
<head>
<title>Invio email</title>
</head>
<script language="javascript">
var sel=new Array(), newsel=new Array(), emptysel=new Array();
function MemMulti(ss){
    newsel.length=0
    for(var i=0;i<ss.options.length;i++)
        if(ss.options[i].selected)
            newsel[newsel.length]=i
    if (sel.length==1 && newsel.length==1 && newsel[0]==sel[0]) {
        ss.options[newsel[0]].selected=false
        sel.length=0;
    } else {
        sel = newsel.concat(emptysel);
    }

}
function SelMulti(ss){
    var ultimo='nessuno'
    for(var i=0;i<ss.options.length;i++)
        if(ss.options[i].selected)
            ultimo=i
            document.getElementById('destinatario').value = document.getElementById('destinatario').value + ss.options[ultimo].value + '\n';
    for(i=0;i<ss.options.length;i++)
        ss.options[i].selected=false
    for(i=0;i<sel.length;i++)
        ss.options[sel[i]].selected=true
    if(ultimo!='nessuno')
        ss.options[ultimo].selected=!ss.options[ultimo].selected
}
</script>

<body>
<table>
    <form method="post" action="?indice=171&lingua=ita">
        <tr>
            <td>Gruppo</td>
            <td>
                <select name='gruppo'>
                    <?php
                          $selGruppo 
"SELECT * FROM gruppo";
                          
$result mysql_query($selGruppo) or die("Errore nella select");
                          while(
$arr mysql_fetch_array($result)) {
                               if(
$arr[0]==$_POST['gruppo']){
                                echo 
"<option value=\"" $arr[0] . "\" selected='selected'>" $arr[1] . "";
                            }
                            else{
                                echo 
"<option value=\"" $arr[0] . "\">" $arr[1] . "";
                            }
                          }
                          
//mysql_close($db);
                      
?>
                  </select>     
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" name="submitIndirizzi" value="Indirizzi">
            </td>
        </tr>
    </form>
    
    <form method="post" action="?indice=210" enctype="multipart/form-data">
    <?
        
if(isset($_POST['gruppo'])){
        
?>

        <tr>
            <td>Indirizzi</td>
            <td>
                <select name="indirizzi" multiple="multiple" onclick="MemMulti(this)" onchange="SelMulti(this)">
                    <?php                  
                        $gruppo 
$_POST['gruppo'];
                        foreach (
$gruppo as $valore){
                        
//    echo $valore;
                        
}
                        
                          
$selNewsletter "SELECT newsletter.id_nl, email_nl FROM newsletter, news_gruppo WHERE newsletter.id_nl = news_gruppo.id_nl AND news_gruppo.id_gruppo=".$gruppo;
                          
$result mysql_query($selNewsletter) or die("Errore nella select");
                          while(
$row mysql_fetch_array($result)) {
                                     
                                     
                                echo 
"<option value=\"".$row["email_nl"]."\">".$row["email_nl"]."";
                                
                        }                    
                    
?>
                </select>
            </td>
        </tr>
            <tr>
                <td colspan="2">
                    <input type="submit" name="submitA" value="Invia">
                </td>
            </tr>
        
        <tr>
            <td> Destinatario: </td>
            <td>        
                <textarea id="destinatario" name="destinatario" rows='20' cols='60'></textarea>
            </td>
        </tr>

        <tr>
            <td> cc: </td>
            <td>        
                <textarea id="cc" name="cc" rows='20' cols='40'></textarea>
            </td>
        </tr>

        <tr>
            <td> Bcc: </td>
            <td>        
                <textarea id="bcc" name="bcc" rows='20' cols='60'></textarea>
            </td>
        </tr>
        
        <?php
        
}
        
?>
        
        <input type="hidden" name="mittente" value="infoatra@bluemail.ch">
            <tr>
                <td> Oggetto: </td>
                <td>
                    <input type="text" name="oggetto" value="" size="60">
                </td>
            </tr>
            
            <tr>
                <td> Allega file: </td>
                <td>
                    <input type="file" name="allegato">
                </td>
            </tr>
            
            <tr>
                <td> Testo: </td>
                <td>
                    <name="testo">
                    <?php
                        $oFCKeditor 
= new FCKeditor('testo') ;
                        
$oFCKeditor->BasePath 'fckeditor/' ;
                        
$oFCKeditor->Value $testo;
                        
$oFCKeditor->Width  "580px";
                        
$oFCKeditor->Height "400px";
                        
$oFCKeditor->Create() ;
                    
?>
                </td>
            </tr>
            
            <tr>
                <td></td>
                <td><input type="submit" name="submit" value="Spedisci"></td>
            </tr>
            
            
    </form>

</table>

</body>
</html>

Codice PHP:

<?php
//recupero i valori dei campi del form
    
$destinatario $_POST['destinatario'];
    
$mittente $_POST['mittente'];    
    
$oggetto stripslashes($_POST['oggetto']);
    
$testo stripslashes($_POST['testo']);
    
$testo strip_tags($testo);
    
$testo str_replace("&agrave;",'à',$testo);
    
$testo str_replace("&auml;",'ä',$testo);
    
$testo str_replace("&eacute;",'é',$testo);
    
$testo str_replace("&egrave;",'è',$testo);
    
$testo str_replace("&igrave;",'ì',$testo);
    
$testo str_replace("&ouml;",'ö',$testo);
    
$testo str_replace("&ograve;",'ò',$testo);
    
$testo str_replace("&oacute;",'ó',$testo);
    
$testo str_replace("&uuml;",'ü',$testo);
    
$testo str_replace("&ugrave;",'ù',$testo);
    
$testo str_replace("&Agrave;",'À',$testo);
    
$testo str_replace("&Auml;",'Ä',$testo);
    
$testo str_replace("&Aacute;",'Á',$testo);
    
$testo str_replace("&Eacute;",'É',$testo);
    
$testo str_replace("&Egrave;",'È',$testo);
    
$testo str_replace("&Ouml;",'Ö',$testo);
    
$testo str_replace("&Ograve;",'Ò',$testo);
    
$testo str_replace("&Oacute;",'Ó',$testo);
    
$testo str_replace("&Uuml;",'Ü',$testo);
    
$testo str_replace("&Ugrave;",'Ù',$testo);
    
$testo str_replace("&ccedil;",'ç',$testo);     
    
    
//valorizzo le variabili relative all'allegato
    
$allegato $_FILES['allegato']['tmp_name'];
    
$allegato_type $_FILES['allegato']['type'];
    
$allegato_name $_FILES['allegato']['name'];
    
//creo 2 variabili che riempirò più avanti....
    
$headers "From: " $mittente;
    
$msg "";
    
//Verifico se il file è stato caricato correttamente via HTTP
    
if (is_uploaded_file($allegato)){
    
//apro e leggo il file allegato
        
$file fopen($allegato'rb'); //rb read binary
        
$data fread($filefilesize($allegato));
        
fclose($file);
        
    
//Adatto il file al momento MIME base64 usando base64_encode
        
$data chunk_split(base64_encode($data));
        
    
//Genero il separatore, che serve per dividere le varie parti del messaggio.
    //Separo la parte testuale dall'allegato
        
$semi_rand md5(time());
        
$mime_boundary "==Multipart_Boundary_x{semi_rand}x";
        
    
//Aggiungo le intestazioni necessarie per l'allegato
        
$headers .= "\nMIME-Version: 1.0\n";
        
$headers .= "Content-Type: multipart/mixed;\n";
        
$headers .= " boundary=\"{$mime_boundary}\"";
        
//$headers .= "Bcc: $destinatario\r\n"; 
        //$headers .= "Bcc: " + $destinatario;
        
        
        
    //definisco il tipo di messaggio (MIME/multi-part)
        
$msg .= "This is a multi-part message in MIME format. \n\n";
        
    
//Metto il separatore
        
$msg .= "--{$mime_boundary}\n";
        
    
//Parte testuale del messaggio
        
$msg .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
        
$msg .= "Content-Transfer-Encoding: 7bit\n\n";
        
$msg .= $testo "\n\n";
        
    
//Metto il separatore
        
$msg .= "--{$mime_boundary}\n";
        
    
//Aggiungo l'allegato al messaggio
        
$msg .= "Content-Disposition: attachment;\n";
        
$msg .= " filename=\"{$allegato_name}\"\n";
        
$msg .= "Content-Transfert_Encoding: base64\n\n";
        
$msg .= $data "\n\n";
        
    
//chiudo con il separatore
        
$msg .= "--{$mime_boundary}--\n";
    }
    else{
        
$msg $testo;
    }
    
    
    
    
//invio la mail
    
if (!empty($cc)) {
         
$headers.= "\r\nCc: " $cc ."\n";
    }

       if (!empty(
$bcc)) {
           
$headers.= "\r\nBcc: " $bcc ."\n";
       }
    
    if(
mail($destinatario$oggetto$msg$headers)){
        echo 
"

Mail inviata con successo!</p>"
;
    }
    else{
        echo 
"

Errore!</p>"
;
    }    
?>

GRAZIE A CHI MI SA DIRE DOVE STA L'INGHIPPO.