Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    278

    problemi email formato html con allegato

    Ciao a tutti ho questo codice:
    Codice PHP:
    $to "mittente@email.it";
    $from "ricevente@email.it";
    $subject "Oggetto del messaggio";
    $content_message file_get_contents("html/corpo_mail.html");
    // a random hash will be necessary to send mixed content
    $separator md5(time());
    // carriage return type (we use a PHP end of line constant)
    $eol PHP_EOL;
    // attachment name
    $filename "biglietti.pdf";
    // encode data (puts attachment in proper format)
    $fd fopen($new_path_array[0], "r"); 
    $contents fread($fdfilesize($new_path_array[0])); 
    $attachment =base64_encode($contents);
    // main header (multipart mandatory)
    $headers "From: ".$from.$eol;
    $headers .= "MIME-Version: 1.0".$eol;
    $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
    $headers .= "Content-Transfer-Encoding: 7bit".$eol;
    $headers .= "This is a MIME encoded message.".$eol.$eol;
    // message
     
    $msg_mail="

    prova</p>"
    ;
    $headers .= "--".$separator.$eol;
    $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
    $headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol
    $headers .= $message_mail.$eol.$eol;
    // attachment
    $headers .= "--".$separator.$eol;
    $headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
    //$headers .= "Content-Type: application/pdf; name=\"".$filename."\"".$eol;
    $headers .= "Content-Transfer-Encoding: base64".$eol;
    $headers .= "Content-Disposition: attachment".$eol.$eol;
    $headers .= $attachment.$eol.$eol;
    $headers .= "--".$separator."--";


    // send message
    if(mail($to$subject,$msg_mail$headers))
    {
    echo 
    "mail inviata";
    }
    else
    {
     echo 
    "problemi invio email";

    La mail arriva regolarmente con il relativo allegato, ma non si visualizza il corpo html del messaggio che per prova ho inserito in $msg_mail.

    Ho sbagliato qualcosa?
    Grazie.

  2. #2
    e il testo dle messaggio da inviare $msg_mail dove è definito?

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    278
    E' presente nel codice ho messo un semplice paragrafo come prova.

  4. #4
    io ti consiglierie di provare con la classe PHPMailer con questa eviti tutti gli headers come puoi vedere nel tutorial : bastano poche righe per fare tutto quello che hai scritto!

    cmq mi sa che sbagli qualcosa negli heders, guarda qua in Example #4 Sending HTML email

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 © 2024 vBulletin Solutions, Inc. All rights reserved.