Salve sto avendo un problema per inviare delle email.

Ho una tabella in un database dove prendo gli indirizzi email e poi invio i messaggi:

Codice PHP:
$dbconn=mysql_connect($host$user$pass) or die (mysql_error()." errore connessione database");
mysql_select_db("my_provalavori",$dbconn) or die (mysql_error()." errore selezione my_provalavori");
$QueryEml=mysql_query("Select * from email_nuovamedia") or die(mysql_error()." errore estrazione email");
while(
$RecEml=mysql_fetch_array($QueryEml)){

$from="Nuovamedia <nuovamedia@gmail.com>";
$intestazioni "From: $from\nX-Mailer: Sismail Web Email Interface\nMIME-version: 1.0\nContent-type: multipart/mixed;\n boundary=\"Message-Boundary\"\nContent-transfer-encoding: 7BIT\nX-attachments: $namefile";  

            
$body_top "--Message-Boundary\n";  
            
$body_top .= "Content-type: text/html; charset=\"utf-8\"\n";  
            
$body_top .= "Content-transfer-encoding: 7BIT\n";  
            
$body_top .= "Content-description: Mail message body\n\n";  
                
            
$msg_body $body_top $text;  
                
            
$msg_body .= "\n\n--Message-Boundary\n";  
            
$msg_body .= "Content-type: $typefile; name=\"$namefile\"\n";  
            
$msg_body .= "Content-Transfer-Encoding: BASE64\n";  
            
$msg_body .= "Content-disposition: attachment; filename=\"$namefile\"\n\n"
            
$msg_body .= "$data\n";  
            
$msg_body .= "--Message-Boundary--\n"

            foreach(
$arremail as $email){
                
$to=$RecEml["Email"];
                
$eml.=$to.", ";
                              
                if(!
mail($to,$object,$msg_body,$intestazioni)){
                    
$errmail.="$ciclo- errore invio $email.
"
;
                }
            }


Il problema e che mi invia le prime 3 email poi tutte le altre mi da errore.