Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. Coding
  5. Invio e-mail fatta ma con problemi

Invio e-mail fatta ma con problemi

Pianificato Fissato Bloccato Spostato Coding
2 Post 2 Autori 498 Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • M
    M
    meeee82
    scritto su ultima modifica di
    User Attivo 0
    #1
    Invio e-mail fatta ma con problemi

    vi mostro la form html e php
    ecco dove inserisco i dati
    <td height="297" bgcolor="#FF6600" align="center">
    <form action="invia_mail.php" method="post" name="scuole" id="scuole">
    <table width="390" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
    <tr align="center">
    <td colspan="3"> <font color="#999999" size="-1" face="Arial">Modulo
    </font></td>
    </tr>
    <tr>
    <td colspan="3"> </td>
    </tr>
    <tr>
    <td width="182"></td>
    <td colspan="2"></td>
    </tr>
    <tr>
    <td align="center"><font face="Arial" size="-1" color="#666666">Scuola</font></td>
    <td colspan="2"><input name="scuola" type="text" id="scuola" maxlength="50"></td>
    </tr>
    <tr>
    <td align="center"><font face="Arial" size="-1" color="#666666">Via</font></td>
    <td colspan="2"><input name="via" type="text" id="via" maxlength="50"></td>
    </tr>
    <tr>
    <td align="center"><font face="Arial" size="-1" color="#666666">Citta</font></td>
    <td colspan="2"><input name="citta" type="text" id="citta" maxlength="50"></td>
    </tr>
    <tr>
    <td align="center" valign="top">
    <font color="#666666" size="-1" face="Arial">Provincia*</font></p></td>
    <td colspan="2" valign="middle">

    <SELECT NAME="provincia">
    <OPTION SELECTED>Seleziona la provincia
    <OPTION>AGRIGENTO
    <OPTION>ALESSANDRIA
    <OPTION>ANCONA
    <OPTION>AOSTA
    <OPTION>AREZZO
    <OPTION>ASCOLI PICENO
    <OPTION>ASTI
    <OPTION>AVELLINO
    <OPTION>BARI
    <OPTION>BELLUNO
    <OPTION>BENEVENTO
    <OPTION>BERGAMO
    <OPTION>BIELLA
    <OPTION>BOLOGNA
    <OPTION>BOLZANO
    <OPTION>BRESCIA
    <OPTION>BRINDISI
    <OPTION>CAGLIARI
    <OPTION>CALTANISSETTA
    <OPTION>CAMPOBASSO
    <OPTION>CASERTA
    <OPTION>CATANIA
    <OPTION>CATANZARO
    <OPTION>CHIETI
    <OPTION>COMO
    <OPTION>COSENZA
    <OPTION>CREMONA
    <OPTION>CROTONE
    <OPTION>CUNEO
    <OPTION>ENNA
    <OPTION>FERRARA
    <OPTION>FIRENZE
    <OPTION>FOGGIA
    <OPTION>FORLI'
    <OPTION>FROSINONE
    <OPTION>GENOVA
    <OPTION>GORIZIA
    <OPTION>GROSSETO
    <OPTION>IMPERIA
    <OPTION>ISERNIA
    <OPTION>LA SPEZIA
    <OPTION>L'AQUILA
    <OPTION>LATINA
    <OPTION>LECCE
    <OPTION>LECCO
    <OPTION>LIVORNO
    <OPTION>LODI
    <OPTION>LUCCA
    <OPTION>MACERATA
    <OPTION>MANTOVA
    <OPTION>MATERA
    <OPTION>MESSINA
    <OPTION>MILANO
    <OPTION>MODENA
    <OPTION>NAPOLI
    <OPTION>NOVARA
    <OPTION>NUORO
    <OPTION>ORISTANO
    <OPTION>PADOVA
    <OPTION>PALERMO
    <OPTION>PARMA
    <OPTION>PAVIA
    <OPTION>PERUGIA
    <OPTION>PESARO
    <OPTION>PESCARA
    <OPTION>PIACENZA
    <OPTION>PISA
    <OPTION>PISTOIA
    <OPTION>PORDENONE
    <OPTION>POTENZA
    <OPTION>PRATO
    <OPTION>RAGUSA
    <OPTION>RAVENNA
    <OPTION>REGGIO CALABRIA
    <OPTION>REGGIO EMILIA
    <OPTION>REPUBBLICA DI SAN MARINO
    <OPTION>RIETI
    <OPTION>RIMINI
    <OPTION>ROMA
    <OPTION>ROVIGO
    <OPTION>SALERNO
    <OPTION>SASSARI
    <OPTION>SAVONA
    <OPTION>SIENA
    <OPTION>SIRACUSA
    <OPTION>SONDRIO
    <OPTION>TARANTO
    <OPTION>TERAMO
    <OPTION>TERNI
    <OPTION>TORINO
    <OPTION>TRAPANI
    <OPTION>TRENTO
    <OPTION>TREVISO
    <OPTION>TRIESTE
    <OPTION>UDINE
    <OPTION>URBINO
    <OPTION>VARESE
    <OPTION>VENEZIA
    <OPTION>VERBANIA
    <OPTION>VERCELLI
    <OPTION>VERONA
    <OPTION>VIBO VALENTIA
    <OPTION>VICENZA
    <OPTION>VITERBO
    </SELECT>

    </p></td>
    </tr>
    <tr>
    <td height="25" align="center"><font face="Arial" size="-1" color="#666666">CAP
    </font></td>
    <td colspan="2"><input name="cap" type="text" id="cap" maxlength="25"></td>
    </tr>
    <tr>
    <td align="center"><font face="Arial" size="-1" color="#666666">Telefono</font></td>
    <td colspan="2"><input name="telefono" type="text" id="telefono" size="30" maxlength="50"></td>
    </tr>
    <tr>
    <td align="center"><font face="Arial" size="-1" color="#666666">FAX</font></td>
    <td colspan="2"><input name="fax" type="text" id="fax" size="30" maxlength="60"></td>
    </tr>
    <tr>
    <td align="center"><font color="#666666" size="-1" face="Arial">e
    mail</font></td>
    <td colspan="2"><input name="email" type="text" id="email" size="30" maxlength="50"></td>
    </tr>
    <tr>
    <td align="center"><font face="Arial" size="-1" color="#666666">Dirigente
    Scolastico</font></td>
    <td colspan="2"><input name="dirigente" type="text" id="dirigente" size="30" maxlength="25"></td>
    </tr>
    <tr>
    <td align="center"><font face="Arial" size="-1" color="#666666">Classe</font></td>
    <td colspan="2"><input name="classe" type="text" id="classe" size="30" maxlength="30"></td>
    </tr>
    <tr>
    <td align="center"><font face="Arial" size="-1" color="#666666">Sezione</font></td>
    <td colspan="2"><input name="sezione" type="text" id="sezione" size="30" maxlength="30"></td>
    </tr>
    <tr>
    <td align="center"> </td>
    <td colspan="2" rowspan="2">

     </td>
    </tr>
    <tr>
    <td> </td>
    </tr>
    <tr>
    <td colspan="3" align="left"><font color="#666666" size="-1" face="Arial">
    Docente Responsabile </font>
    <input name="docente" type="text" id="docente" size="26" maxlength="15"></td>
    </tr>
    <tr>
    <td colspan="3" align="center"></td>
    </tr>
    <tr>
    <td colspan="2">Allega file:  <input type="file" name="allegato" /></td>
    </tr>
    <tr>
    <td colspan="3"><div align="center"><font size="-2" face="Arial"><font color="#666666">Informativa
    art. 13 D.lgs. 196/2003
    Ai sensi dell'art. 13 del D.lgs. n.196/2003, Le forniamo, quindi,
    le seguenti informazioni:

    • I dati da Lei forniti verranno trattati esclusivamente per
      finalità concernenti l'attività di

    • Il conferimento dei dati è facoltativo e l'eventuale
      rifiuto a fornire tali dati non ha alcuna conseguenza.

    • I dati da Lei forniti non saranno oggetto di diffusione.</font>
      </font></div></td>
      </tr>
      <tr>
      <td colspan="2" align="right"> <input name="invia modulo" type="submit" id="invia2" value="Invia">
      </td>
      <td align="center" width="78"> <input name="reimposta" type="reset" id="reimposta2" value="reimposta"></td>
      </tr>
      </table>
      </form>
      <form method="POST" action="invia_mail.php" onsubmit="return FrontPage_Form2_Validator(this)" language="JavaScript" name="FrontPage_Form2" enctype="multipart/form-data">
      <div align="center">
       </div>
      </form>
      </td>
      </tr>
      </table>
      </div>
      ECCO IL PHP DI INVIO

      <?PHP
      $scuola = $_POST['scuola'];
      $via = $_POST['via'];
      $citta= $_POST['citta'];
      $provincia = $_POST['provincia'];
      $cap = $_POST['cap'];
      $telefono = $_POST['telefono'];
      $fax= $_POST['fax'];
      $email = $_POST['email'];
      $digigente = $_POST['dirigente'];
      $classe = $_POST['classe'];
      $sezione= $_POST['sezione'];
      $docente = $_POST['docente'];
      $destinatario = 'miaemail';
      //$mittente = "Da: " . $e_mail;

    $messaggio = "ARGOMENTO: $argomento\n\nMessaggio: $messaggio";
    // Valorizzo le variabili relative all'allegato
    $allegato = $_FILES['allegato']['tmp_name'];
    $allegato_type = $_FILES['allegato']['type'];
    $allegato_name = $_FILES['allegato']['name'];
    // Creo 2 variabili che riempirò più avanti...
    $headers = "From: " . $e_mail;
    $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/plain; charset="iso-8859-1"\n";
    $msg .= "Content-Transfer-Encoding: 7bit\n\n";
    $msg .= $scuola . "\n\n";
    // Metto il separatore
    $msg .= "--{$mime_boundary}\n";
    // Aggiungo l'allegato al messaggio
    $msg .= "Content-Disposition: attachment;\n";
    $msg .= " filename="{$allegato_name}"\n";
    $msg .= "Content-Transfer-Encoding: base64\n\n";
    $msg .= $data . "\n\n";
    // chiudo con il separatore
    $msg .= "--{$mime_boundary}--\n";
    }
    else
    {
    $msg = $scuola;
    }
    if (mail($destinatario, $oggetto, $msg, $headers))
    {
    echo "<p>Mail inviata con successo!</p>";
    }else{
    echo "<p>Errore!</p>";
    }
    ?>

    come mai nn mi appare ne l'allegato ne niente mi arriva l'email vuota??

    1 Risposta Ultima Risposta
    Miglior risposta 0
    0
    • S
      S
      satifal
      scritto su ultima modifica di
      User 0
      #2

      Nel codice che utilizzo io definisco header e body nella maniera seguente e tutto funziona correttamente:

         $destinatario = "xxx"; 
         $subject = "yyy";
         $mittente = "\"zzz\" <[email protected]>";
         $message = "testo del messaggio";
      
         $attach = $_FILES['attach']['tmp_name'];
         $filetype = $_FILES['attach']['type'];
         $nomeAllegato = $_FILES['attach']['name'];
      
      if (is_uploaded_file($attach)) {
         $filez = fopen($attach, "r");
         $contents = fread($filez, filesize($attach));
         $encoded_attach = chunk_split(base64_encode($contents));
         fclose($filez);
         
         // CREO L'INTESTAZIONE
         $header = "From: $mittente\n";
         $header .= "X-Mailer: Sismail Web Email Interface\n";
         $header .= "MIME-version: 1.0\n";
         $header .= "Content-type: multipart/mixed;\n";
         $header .= " boundary=\"Message-Boundary\"\n";
         $header .= "Content-transfer-encoding: 7BIT\n";
         $header .= "X-attachments: $nomeAllegato";
                   
         // CREO IL MESSAGGIO
         $body = "--Message-Boundary\n";
         $body .= "Content-type: text/plain; charset=iso-8859-1\n";
         $body .= "Content-transfer-encoding: 7BIT\n";
         $body .= "Content-description: Mail message body\n\n";
         $body .= $message . "\n\n";
         $body .= "\n\n--Message-Boundary\n";
         $body .= "Content-type: $filetype; name=\"$nomeAllegato\"\n";
         $body .= "Content-Transfer-Encoding: BASE64\n";
         $body .= "Content-disposition: attachment; filename=\"$nomeAllegato\"\n\n";
         $body .= "$encoded_attach\n";
         $body .= "--Message-Boundary--\n";
      
         @mail($destinatario, $subject, $body, $header);
      }
      
      1 Risposta Ultima Risposta
      Miglior risposta 0
      0

      Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

      Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

      Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

      Registrati Accedi
      Rispondi
      • Risposta alla discussione
      Effettua l'accesso per rispondere
      • Da Vecchi a Nuovi
      • Da Nuovi a Vecchi
      • Più Voti


      • Accedi

      • Non hai un account? Registrati

      • Accedi o registrati per effettuare la ricerca.
      • Primo post
        Ultimo post
      Home Accedi Registrati
      Menu
      • CATEGORIES
      • La Community Connect.gt
      • Presentati alla Community
      • News Ufficiali da Connect.gt
      • Internet News
      • A Scuola Di
      • Digital Marketing
      • Intelligenza Artificiale
      • SEO & GEO
      • Web Marketing e Content
      • Google Analytics e Web Analytics
      • Google Ads & Advertising
      • YouTube
      • TikTok, Instagram e altri Social
      • Google Adsense, Affiliazioni e Guadagno
      • E-Commerce
      • Coding e Sistemistica
      • Help Center: consigli per il tuo progetto
      • Hosting e Cloud
      • Coding
      • CMS & Piattaforme Self-Hosted
      • Annunci e Collaborazioni
      • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
      • Collaborazioni WEB e Lavoro: offro e cerco
      • Impresa, Fisco e Leggi
      • Consulenza Legale e Professioni Web
      • Consulenza Fiscale, Imprese, Startup e P.Iva
      • Gli Off Topic
      • PC, Smartphone e altri Hardware
      • Tutti i Software
      • GT Fetish Cafè
      • Discussioni
      • Non letti 0
      • Recenti
      • Hashtag
      • Popolare
      • Utenti
      • Privacy
      • Termini e condizioni
      • © 2026 Search On Media Group S.r.l.