[HTML] Testo mail non visualizzabile su IOS

Alex@1983

Utente Attivo
9 Mag 2015
126
2
18
Ciao a tutti ,

vi chiedo aiuto per il seguente problema : ho un registro che , nel momento in cui viene compilato , invia una mail in formato html con i dettagli dell' evento registrato inseriti in una normale table . Tutto funziona correttamente fatta eccezione per il fatto che ,se si cerca di visualizzare la mail con un sistema IOS , la table appare completamente vuota , si vedono bordi e background ma non il testo , come se i campi non fossero compilati .

Il codice che utilizzo per l'invio della mail è il seguente , in pratica verifica se è stata caricata una foto da allegare , altrimenti invia la mail così come definito in $dascrivere

Grzie in anticipo !!!!!

PHP:
$dascrivere = '<html>
                    <body>
       <style>
         table { background-color: #FFF7E3; color: #000000; border-color: #000000; font-size : 20 }
   </style>
  <table border="1" cellpadding="8">
  <tr>
    <th colspan="2" style="text-align : center ; font-size="xx-large">ISPEZIONE ID:   '.$idIsp.'</th>
  </tr>
 <tr>
    <th>DATA</th>
    <td>'.$dataOra.'</td>
  </tr>
  <tr>
    <th>OPERATORE</th>
    <td>'.$operatore.'</td>
  </tr>
  <tr>
    <th>OPERAZIONE</th>
    <td>'.$operazione.'</td>
  </tr>
  <tr>
    <th>RICHIEDENTE</th>
    <td>'.$richiedente.'</td>
  </tr>
  <tr>
    <th>ESITO</th>
    <td>'.$esito.'</td>
  </tr>
  <tr>
    <th>DESCRIZIONE</th>
    <td>'.$descrizione.'</td>
  </tr>
   <tr>
    <th>NOTE</th>
    <td>'.$note.'</td>
  </tr>
    <tr>
    <th>INOLTRO MAIL</th>
    <td>'.$destinatarimail.'</td>
  </tr>
</table>

</body>
</html>';
/////////////////////////////////////////////////////////////////////////////////////////////////
                                                                                                                                                                                               
// Recupero il valore dei campi del form

$destinatario = "[email protected], [email protected], $destinatarimail";
$mittente = "Registro Operazioni<[email protected]>";
$oggetto = "Inserita nuova Operazione";
$messaggio =  '<html>
                    <body>
       <style>
         table { background-color: #FFF7E3; color: #000000; border-color: #000000; font-size : 20 }
   </style>
  <table border="1" cellpadding="8">
  <tr>
    <th colspan="2" style="text-align : center ; font-size="xx-large">OPERAZIONE  ID:   '.$idIsp.'</th>
  </tr>
 <tr>
    <th>DATA</th>
    <td>'.$data.'</td>
  </tr>
  <tr>
    <th>OPERATORE</th>
    <td>'.$operatore.'</td>
  </tr>
  <tr>
    <th>OPERAZIONE</th>
    <td>'.$operazione.'</td>
  </tr>
  <tr>
    <th>RICHIEDENTE</th>
    <td>'.$richiedente.'</td>
  </tr>
  <tr>
    <th>ESITO</th>
    <td>'.$esito.'</td>
  </tr>
  <tr>
    <th>DESCRIZIONE</th>
    <td>'.$descrizione.'</td>
  </tr>
   <tr>
    <th>NOTE</th>
    <td>'.$note.'</td>
  </tr>
  <tr>
    <th>FOTO</th>
    <td>'.$_FILES['foto']['name'].'</td>
  </tr>
</table>
</body>
</html>';

// Valorizzo le variabili relative all'allegato
$allegato = $_FILES['foto']['tmp_name'];
$allegato_type = $_FILES['foto']['type'];
$allegato_name = $_FILES['foto']['name'];

// Creo altre due variabili ad uno interno
$headers = "From: " . $mittente;
$msg = "";

// Verifico se il file è stato caricato correttamente via HTTP
// In caso affermativo proseguo nel lavoro...
if (is_uploaded_file($allegato))
{
  // Apro e leggo il file allegato
  $file = fopen($allegato,'rb');
  $data = fread($file, filesize($allegato));
  fclose($file);

  // Adatto il file al formato MIME base64 usando base64_encode
  $data = chunk_split(base64_encode($data));

  // Genero il "separatore"
  // Serve per dividere, appunto, le varie parti del messaggio.
  // Nel nostro caso separerà la parte testuale dall'allegato
  $semi_rand = md5(time());
  $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
 
  // Aggiungo le intestazioni necessarie per l'allegato
  $headers .= "\nMIME-Version: 1.0\n";
  $headers .= "Content-Type: multipart/mixed;\n";
  $headers .= " boundary=\"{$mime_boundary}\"";

  // Definisco il tipo di messaggio (MIME/multi-part)
  $msg .= "This is a multi-part message in MIME format.\n\n";

  // Metto il separatore
  $msg .= "--{$mime_boundary}\n";

  // Questa è la parte "testuale" del messaggio
  //$msg .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
 
    $msg .= "Content-Type: text/html; charset=\"UTF-8\"\n";
    $msg .= "Content-Transfer-Encoding: 7bit\n\n";
  $msg .= $messaggio . "\n\n";

  // Metto il separatore
  $msg .= "--{$mime_boundary}\n";

  // Aggiungo l'allegato al messaggio
  $msg .= "Content-Disposition: attachment; filename=\"{$allegato_name}\"\n";
  $msg .= "Content-Transfer-Encoding: base64\n\n";
  $msg .= $data . "\n\n";

  // chiudo con il separatore
  $msg .= "--{$mime_boundary}--\n";
}
// se non è stato caricato alcun file
// preparo un semplice messaggio testuale
else
{
 $msg = $dascrivere;
  
$headers = "MIME-Version: 1.0\r\n";                                                                                                                                     //---//
$headers .= "From: Registro Operazioni<[email protected]>\r\n";                                                             //---//
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";                                                                                 //---//
$headers .= "Content-Transfer-Encoding: 7bit\r\n";                                                                                                             //----//
                                                                     
}

// Invio la mail
if (mail($destinatario, $oggetto, $msg, $headers))
{
  echo "<p>Mail inviata con successo!</p>";
}else{
  echo "<p>Errore!</p>";
}
 
Ultima modifica:
Discussioni simili
Autore Titolo Forum Risposte Data
IImanuII Mail in php da testo a html PHP 40
IImanuII Form mail scelta se inviare il testo in html PHP 5
S [HTML] Effetto su testo da togliere HTML e CSS 0
R [HTML] Effetto carousel di testo su immagine fissa HTML e CSS 2
D [Javascript] [HTML] Evidenziare testo di una text Javascript 1
S [HTML] Centrare verticalmente il testo in div HTML e CSS 2
bubino8 [HTML] <input type="file"> Testo a scelta HTML e CSS 3
G [HTML] Posizionamento testo in un div HTML e CSS 5
Kolop [HTML] Testo su immagine HTML e CSS 6
I [HTML] Codice box testo con scrollbar sopra immagine HTML e CSS 1
F [HTML] Centrare testo rispetto l'immagine HTML e CSS 1
S [HTML] Box immagine e testo HTML e CSS 1
utente testo scorrevole html da file txt o xml HTML e CSS 6
F [HTML] Inserire testo all'interno di una div con border radius HTML e CSS 2
M Editor di testo HTML/CSS HTML e CSS 7
V Consiglio su testo Html e Css HTML e CSS 3
I recuperare testo da una pagina web html Ajax 2
J inserimento testo in html prelevato da altro sito SEO e Posizionamento 4
C File di testo da html HTML e CSS 2
L Creazione tabella Html con popolazione dati da file di testo (txt) Ajax 12
C in un file html/javascript caricare i div presenti nel body in un file di testo e richiamarli Javascript 7
M Allineamento Testo html css, help HTML e CSS 1
P HTML - rendere cliccabile parte del testo HTML e CSS 2
M Modificare il testo di un documento HTML Javascript 2
valens Errori di validazione del testo html HTML e CSS 5
A formattare testo html PHP 2
F Aggiornamento testo pagina html Classic ASP 2
G Pagina html in stringa PHP 2
E Sostituzione Elemento Html PHP 3
G Elementi HTML HTML e CSS 1
K Visualizzare del html responsive in una Webview Sviluppo app per Android 0
T Domanda valutazione html LinkedIn 2022 pt3 HTML e CSS 7
T Domanda valutazione html LinkedIn 2023 pt2 HTML e CSS 15
T Domanda valutazione html LinkedIn 2023 pt1 HTML e CSS 1
MarcoGrazia Salvataggio HTML in database PHP 2
K posizionare variabile da pagina html all'iframe. Javascript 1
peppe0703 Come Estrarre dati da db wordpress e richiamarli in html esterno HTML e CSS 0
L problema collegamento file css con html HTML e CSS 1
D Informazioni da XAMPP su HTML PHP 0
R Immagini html HTML e CSS 2
K File audio in html, chi mi può aiutare? HTML e CSS 0
K Aiuto con file audio in html HTML e CSS 1
Antonio67 Lanciare file shell bash da html HTML e CSS 2
M Riportare in tabella HTML dati estratti con query SQL MySQL 0
G Codice html Javascript 1
M Collegamento tra form html e script php PHP 4
L Ricezione dei dati su file php da modulo html PHP 6
F Creare elementi html con javascript Javascript 3
G Appicazione HTML per inserimento dai in Database Access Microsoft HTML e CSS 0
W visualizzare solo file html e sottocartelle di una cartella PHP 1

Discussioni simili