Newsgroup: it.comp.www.php
Titolo: Mi sono incartata

Qualcuno puo' aiutarmi nel controllare questo script a cui non riesco
a far inviare l'email?
<?
include( "config.php");
$Bcc="";
$pagina="grazie01.htm";
/* connessione al database MySql (per la connessione persistente si
può modificare in mysql_pconnect) */
$connected = @mysql_connect($db_host, $db_login, $db_pass)
  or die("non posso connettermi a '".$db_host."'<br />".
   "Controlla i settaggi!");
mysql_select_db($database) or die("Devi prima creare il Database
'".$db['database']."' !"); ;
$sql = "Select * from mailuser where id=$id";
$res = mysql_query($sql);
if ($res && mysql_num_rows($res)>0)  {
   $to = mysql_Result($res, 0, 'mailins');
   $nomei = mysql_Result($res, 0, 'nomeins');
}
  if($_POST['Invia'] == "Invia") {
    function get_mime($filename)
     {
      $file_extension = substr($filename,strpos($filename,"."));
      $mime_list = array(
                         'gif'	=> 'image/gif',
'jpg'	=> 'image/jpeg',
'jpeg'	=> 'image/jpeg',
'jpe'	=> 'image/jpeg',
'bmp'	=> 'image/bmp',
'png'	=> 'image/png',
'tif'	=> 'image/tiff',
'tiff'	=> 'image/tiff',
'swf'	=> 'application/x-shockwave-flash'
);
      $mime_type = in_array($file_extension,array_keys($mime_list)) ?
      $mime_list[$file_extension] : false;
      return $mime_type;
     }
    function build_extras_images($body_img)
     {
      $extras = array();
      $x = 0;
      if(count($body_img) >=1 ) {
        foreach($body_img as $img_file) {
          if(file_exists($img_file)) {
            $size = filesize($img_file);
            $extras[$x]["id"] = uniqid(time());
            $extras[$x]["name"] = basename($img_file);
            $extras[$x]["type"] = get_mime($img_file);
            $fd = fopen($img_file, "r");
            $extras[$x]["contents"] =
chunk_split(base64_encode(fread($fd, $size)));
            fclose($fd);
            unlink($img_file);
            ++$x;
           }
         }
       }
      return $extras;
     }
    function build_img_header($boundary, $img_info = array())
     {
      $extras_body  = "------=_$boundary\n";
      $extras_body .= "Content-Type: ".$img_info["type"].";
      name=\"".$img_info["name"]."\"\n";
      $extras_body .= "Content-Transfer-Encoding: BASE64\n";
      $extras_body .= "Content-ID: <".$img_info["id"].">\n\n";
      $extras_body .= $img_info["contents"]."\n";
      return $extras_body;
     }
    function send_mail($to, $Bcc, $from, $name_from, $subject,
$text_body, $html_body,
    $extras_image)
     {
      $message_boundary = "NextPart_".uniqid(time());
      $related_boundary = "NextPart_".uniqid(time());
      $headers  = "From: $name_from <$from>\n";
      $headers .= "Return-Path: $from\n";
      $headers .= "Bcc: $Bcc\n";
      $headers .= "MIME-Version: 1.0\n";
      $headers .= "Content-type: multipart/related;
      boundary=\"----=_$related_boundary\"; type:
multipart/alternative\n\n";
      $headers .= "Messaggio in formato MIME composto da più
parti.\n\n";
      $headers .= "------=_$related_boundary\n";
      $headers .= "Content-type: multipart/alternative;
      boundary=\"----=_$message_boundary\"\n\n";
      $headers .= "------=_$message_boundary\n";
      $headers .= "Content-Type: text/plain;
charset=\"iso-8859-1\"\n\n";
      $headers .= $text_body."\n\n";
      $headers .= "------=_$message_boundary\n";
      $headers .= "Content-type: text/html;
charset=\"iso-8859-1\"\n\n";
      $headers .= $html_body."\n\n";
      $headers .= "------=_$message_boundary--\n";
      foreach($extras_image as $image) {
        $headers .= build_img_header($related_boundary, $image);
       }
      $headers .= "------=_$related_boundary--\n";
      if(mail($to, $subject, "", $headers)) {
      //echo "mail inviata";
      //return thank you page
      Header("Location: $pagina");
       }
      else {
        echo "Errore nell'invio";
       }
     }
    // numero di immagini
    $max_img = 3;
    $upload_dir = "upload/";
    for($x = 1; $x <= $max_img; ++$x) {
      $input = "img".$x;
      if(trim($_FILES[$input]['name']) != "" &&
get_mime($_FILES[$input]['name'])
      !== false) {
        if(@is_uploaded_file($_FILES[$input]['tmp_name'])) {
          if(@move_uploaded_file($_FILES[$input]['tmp_name'],
          $upload_dir.$_FILES[$input]['name'])) {
            $image_path[] = $upload_dir.$_FILES[$input]['name'];
           }
         }
       }
      else {
        echo $_FILES[$input]['name']." <br>";
       }
     }
    if(count($image_path) > 0) {
      $image_info = build_extras_images($image_path);
     }
    // destinatario
    // $to = "
vi...@email.it
";
    // mittente
    $from = $_POST['mailv'];
    // nome mittente
    $name_from = $_POST['nomev'];
    // oggetto del messaggio
    $subject = "Vs richiesta";
    // corpo messaggio in formato html
    $html_body = "<html>
                   <head>
                    <meta content=\"text/html; charset=iso-8859-1\">
                   </head>
                   <body>
<b>".strip_tags($_POST['testo'])."</b><center><br>\n";
    foreach($image_info as $print_image) {
      $html_body .= "<img border=0
src=\"cid:".$print_image["id"]."\"><br><br><br><br>\n\n\n\n";
     }
    $html_body .= " </center>
                   </body>
                  </html>\n";
   // corpo del messaggio in formato solo testo
   $text_body = trim(strip_tags($html_body));
   // invio e-mail
   send_mail($to, $Bcc, $from, $name_from, $subject, $text_body,
$html_body, $image_info);
  }
 else {
?>

     // $to = "
vi...@email.it
";
Può essere in questo remember il problema?
-- 
Message sent from: 
http://www.fanwars.it
 
IP ADDRESS: 80.182.247.165 
TIME: 19-04-2003 00:32