Why my script don't work?
I tried with xampp and with online host.
I tried with $headers = "From: $from \r\n";
I got "Sent successfully!" but I don't recieve any mail.
        $to = "********";
        $from = $_POST['email'];
        $nume = $_POST['nume'];
        $prenume = $_POST['prenume'];
        $phone = $_POST['telefon'];
        $oras = $_POST['oras'];
        $adresa = $_POST['adresa'];
        $facultate = $_POST['facultate'];
        $titlu1 = $_POST['titlu1'];
        $desc1 = $_POST['desc1'];
        $titlu2 = $_POST['titlu2'];
        $desc2 = $_POST['desc2'];
        $titlu3 = $_POST['titlu3'];
        $desc3 = $_POST['desc3'];
        $subject = "Luminile Iernii - Inscriere: $nume $prenume";
        $message = " Nume si Prenume: $nume $prenume \n Email: $from \n Nr. Telefon: $phone \n Oras: $oras \n Adresa: $adresa \n Institutia de invatamant: $facultate \n  Titlu Fotografie 1: $titlu1 \n Descriere Fotografie 1: $desc1 \n  Titlu Fotografie 2: $titlu2 \n Descriere Fotografie 2: $desc2 \n  Titlu Fotografie 3: $titlu3 \n Descriere Fotografie 3: $desc3 \n ";
    // Temporary paths of selected files
    $file1 = $_FILES['file1']['tmp_name'];
    $file2 = $_FILES['file2']['tmp_name'];
    $file3 = $_FILES['file3']['tmp_name'];
    // File names of selected files
    $filename1 = "Fotografie 1";
    $filename2 = "Fotografie 2";
    $filename3 = "Fotografie 3";
    // array of filenames to be as attachments
    $files = array($file1, $file2, $file3);
    $filenames = array($filename1, $filename2, $filename3);
    // include the from email in the headers
    $headers = "From: $from";
    // boundary
    $time = md5(time());
    $boundary = "==Multipart_Boundary_x{$time}x";
</code>
Is boundary necessary with attachment?
<code>
    // headers used for send attachment with email
    $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$boundary}\"";
    // multipart boundary
    $message = "--{$boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$boundary}\n";
    // attach the attachments to the message
    foreach( $files as $key => $value )
    {
        if( empty( $value ) )
        {
            unset( $files[$key] );
            unset( $filenames[$key] );
        }
    }
    for($x = 0; $x < count($files); $x++) {
        $file = fopen($files[$x], "r");
        $content = fread($file,filesize($files[$x]));
        fclose($file);
        $content = chunk_split(base64_encode($content));
        $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$filenames[$x]\"\n" . "Content-Transfer-Encoding: base64\n\n" . $content . "\n\n";
        $message .= "--{$boundary}\n";
    }
    // sending mail
    $sendmail = mail($to, $subject, $message, $headers);
    // verify if mail is sent or not
    if ($sendmail) {
        echo "Sent successfully!";
    } else {
        echo "Error occurred. Try again!";
    }
</code>
Someone can exaplin to me?
I don't get it... what I did wrong?
 
     
    