Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    Invio email con allegato

    ciao,mi servirebbe il vostro aiuto.
    Ho questo script per l'invio di email con allegato,io ci ho aggiunto la variante
    $subj,funziona tutto benissimo.Io vorrei che il testo delle due varianti $from_name è $from
    andassero a capo.E possibile ?io ho provato con "\n" o "\r\n" ma se le aggiungo non mi manda più l'email.


    Codice PHP:
    <? 
    $subj
    "Questo messaggio ti è stato inviato da : $from_name . Email :  $from . Testo :";
    // Variabili passate dal form: 
    // $dest            -> Indirizzo e-mail del destinatario 
    // $dest_name       -> Nome del destinatario dell'email 
    // $from            -> E-Mail di chi spedisce 
    // $from_name       -> Nome di chi spedisce 
    // $subject         -> Oggetto dell'email 
    // $body            -> Corpo del messaggio 
    // $body_color      -> Colore di sfondo da dare alla pagina html 
    // $immagine        -> URL dell'immagine 

    $boundary md5(uniqid(microtime())); // Delimitatore 

    // Qui mi trovo il mime_type e l'estensione dell'immagine 
    $inf_imm=@GetImageSize($immagine); 
    if (
    $inf_imm[2]==1) {$ext="gif"$mime_type="image/gif";} 
    else if (
    $inf_imm[2]==2) {$ext="jpg"$mime_type="image/jpeg";} 
    else if (
    $inf_imm[2]==3) {$ext="png"$mime_type="image/png";} 
    else if (
    $inf_imm[2]==6) {$ext="bmp"$mime_type="image/bmp";} 

    $attach_name="cartolina.".$ext;   // Nome da dare all'allegato 

    // Intestazione 
    $msg_headers ="From: \"".$from_name."\" <".$from.">\n"
    $msg_headers.="Reply-To: $from\n"
    $msg_headers.="MIME-version: 1.0\n"
    $msg_headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n"
    $msg_headers.="Content-transfer-encoding: 7BIT\n"
    $msg_headers.="X-Priority: 3\n"
    $msg_headers.="X-Mailer: PHP\n"
    $msg_headers.="X-attachments: $attach_name\n"

    // Inclusione dell'immagine 
    $filex fopen($immagine"r"); 
    $file_content fread($filexfilesize($immagine)); 
    $file_encoded chunk_split(base64_encode($file_content)); 
    fclose($filex); 
    $msg_body  "--".$boundary."\n"
    $msg_body .= "Content-Type: ".$mime_type."; name=\"$attach_name\"\n"
    $msg_body .= "Content-Transfer-Encoding: base64\n"
    $msg_body .= "Content-disposition: attachment; filename=\"".$attach_name."\"\n\n"
    $msg_body .= "$file_encoded\n"
    $msg_body .= "--".$boundary."\n"

    // Inclusione del corpo in formato HTML 
    $msg_body .= "Content-Type: text/html; charset=\"iso-8859-1\"\n"
    $msg_body .= "Content-transfer-encoding: 7BIT\n"
    $msg_body .= "Content-Description: Mail message body\n\n"
    $msg_body .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"
    $msg_body .= "<html><head>\n"
    $msg_body .= "<meta http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">\n"
    $msg_body .= "<body bgcolor=\"".$body_color."\">\n"
    $msg_body .= $subj;
    $msg_body .= $body// Corpo del messaggio passato tramite form 
    $msg_body .= "</body></html>\n"
    $msg_body .= "--".$boundary."\n"

    if (!(@
    mail($dest,$subject,$msg_body,$msg_headers))) 
            {echo 
    "E-Mail non inviata";} 
    else {echo 
    "E-Mail inviata";} 
    ?>
    ciao Gianfranco

  2. #2
    è un'email in html per andare a capo usa
    ciao

  3. #3
    buongiorno,grazie funzia alla grande.
    ciao

  4. #4
    ciao a tutti,visto le numerose visite al mio quesito
    vi posto il codice finale che verrà visualizzato come da esempio :

    18/07/2007 18:32:35
    Questo messaggio ti è stato inviato da : Gianni .
    Email : xxxxxxxxxxx@xxxxx.it .
    Testo del messaggio :
    dovrebbe venire la pagina verde.

    Codice PHP:
    <? 
    $vardataora 
    date("d/m/Y H:i:s");
    $subj"$vardataora
    Questo messaggio ti è stato inviato da : 
    $from_name .
     Email :  
    $from .
     Testo del messaggio :
    "
    ;
    // Variabili passate dal form: 
    // $dest            -> Indirizzo e-mail del destinatario 
    // $dest_name       -> Nome del destinatario dell'email 
    // $from            -> E-Mail di chi spedisce 
    // $from_name       -> Nome di chi spedisce 
    // $subject         -> Oggetto dell'email 
    // $body            -> Corpo del messaggio 
    // $body_color      -> Colore di sfondo da dare alla pagina html 
    // $immagine        -> URL dell'immagine 

    $boundary md5(uniqid(microtime())); // Delimitatore 

    // Qui mi trovo il mime_type e l'estensione dell'immagine 
    $inf_imm=@GetImageSize($immagine); 
    if (
    $inf_imm[2]==1) {$ext="gif"$mime_type="image/gif";} 
    else if (
    $inf_imm[2]==2) {$ext="jpg"$mime_type="image/jpeg";} 
    else if (
    $inf_imm[2]==3) {$ext="png"$mime_type="image/png";} 
    else if (
    $inf_imm[2]==6) {$ext="bmp"$mime_type="image/bmp";} 

    $attach_name="cartolina.".$ext;   // Nome da dare all'allegato 

    // Intestazione 
    $msg_headers ="From: \"".$from_name."\" <".$from.">\n"
    $msg_headers.="Reply-To: $from\n"
    $msg_headers.="MIME-version: 1.0\n"
    $msg_headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n"
    $msg_headers.="Content-transfer-encoding: 7BIT\n"
    $msg_headers.="X-Priority: 3\n"
    $msg_headers.="X-Mailer: PHP\n"
    $msg_headers.="X-attachments: $attach_name\n"

    // Inclusione dell'immagine 
    $filex fopen($immagine"r"); 
    $file_content fread($filexfilesize($immagine)); 
    $file_encoded chunk_split(base64_encode($file_content)); 
    fclose($filex); 
    $msg_body  "--".$boundary."\n"
    $msg_body .= "Content-Type: ".$mime_type."; name=\"$attach_name\"\n"
    $msg_body .= "Content-Transfer-Encoding: base64\n"
    $msg_body .= "Content-disposition: attachment; filename=\"".$attach_name."\"\n\n"
    $msg_body .= "$file_encoded\n"
    $msg_body .= "--".$boundary."\n"

    // Inclusione del corpo in formato HTML 
    $msg_body .= "Content-Type: text/html; charset=\"iso-8859-1\"\n"
    $msg_body .= "Content-transfer-encoding: 7BIT\n"
    $msg_body .= "Content-Description: Mail message body\n\n"
    $msg_body .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"
    $msg_body .= "<html><head>\n"
    $msg_body .= "<meta http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">\n"
    $msg_body .= "<body bgcolor=\"".$body_color."\">\n"
    $msg_body .= $subj;
    $msg_body .= $body// Corpo del messaggio passato tramite form 
    $msg_body .= "</body></html>\n"
    $msg_body .= "--".$boundary."\n"

    if (!(@
    mail($dest,$subject,$msg_body,$msg_headers))) 
            {echo 
    "E-Mail non inviata";} 
    else {echo 
    "E-Mail inviata";} 
    ?>

    ciao Gianfry

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.