Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 15

Discussione: mail html con php

  1. #1
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    84

    mail html con php

    ciao a tutti, ho uno script per inviare un email a una serie di indirizzi inseirti in un file text
    finq qui tutto bene, le email vengono inviate e anche ricevute, per ora posso però inviare solo mail di testo e se io volessi inviare mail html che cosa dovrei cambiare al codice?
    questa è la pagina inviamail.php
    Codice PHP:
    <?php
    // read the list of emails from the file.
    $email_list file("elist.txt");
     
    // count how many emails there are.
    $total_emails count($email_list);
     
    // go through the list and trim off the newline character.
    for ($counter=0$counter<$total_emails$counter++) {
       
    $email_list[$counter] = trim($email_list[$counter]);
       }
     
    // implode the list into a single variable, put commas in, apply as $to value.
    $to implode(",",$email_list);
     
    $subject "BOLLETTINO Angeli per un giorno";
    $message "<html><body>

    ciao mondo</p></body></html>"
    ;
    $headers "From: [email]bollettino@xxxxxxxxxxx.it[/email]";

    if ( 
    mail($to,$subject,$message,$headers) ) {
       echo 
    "The email has been sent!";
       } else {
       echo 
    "The email has failed!";
       }
    ?>
    come potete vedere ho provato a mettere un messaggio in html ma ovviamente artriva il codice html sotto forma di testo con più provider email, non si tratta quinid di un problema legato al provider mail.
    spero possaite aiutarmi.
    grazie a tutti ragazzi siete fantastici

  2. #2
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    356
    guarda l'esempio #4 riportato qui ---> http://php.net/manual/en/function.mail.php

    cmq quello che devi modificare è l'header dell'e-mail...o meglio...devi aggiungere un po' di informazioni...
    Jekkil

  3. #3
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    84
    l hodiventa così:
    Codice PHP:
    <?php
    // read the list of emails from the file.
    $email_list file("elist.txt");
     
    // count how many emails there are.
    $total_emails count($email_list);
     
    // go through the list and trim off the newline character.
    for ($counter=0$counter<$total_emails$counter++) {
       
    $email_list[$counter] = trim($email_list[$counter]);
       }
     
    // implode the list into a single variable, put commas in, apply as $to value.
    $to implode(",",$email_list);
     
    $subject "BOLLETTINO Angeli per un giorno";
    $message "<html><body>

    ciao mondo</p></body></html>"
    ;
    $headers "From: [email]bollettino@axxxxxxxxxxxxx.it[/email]";
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

    if ( 
    mail($to,$subject,$message,$headers) ) {
       echo 
    "The email has been sent!";
       } else {
       echo 
    "The email has failed!";
       }
    ?>
    adesso mi arriva in html ma non si vede più il mittente, l'indirizzo di provenienza è quello del server.
    come mai?
    grazie mille

  4. #4
    Sabba ti ho risposto su Altervista, te lo riporto anche qui. Devi modificare gli headers così:

    Codice PHP:
    $headers  'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $headers .= 'From: bollettino(a)xxxxx.it' "\r\n"
    Social Network in costruzione.. Misto tra Twitter e Facebook.. Twitbook o facetter?

  5. #5
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    356
    non si vede il mittente perchè dopo la riga del From devi mettere \r\n
    Jekkil

  6. #6
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    84
    ciao grazie ho fatto come hai detto tu
    Codice PHP:
    <?php
    // read the list of emails from the file.
    $email_list file("elist.txt");
     
    // count how many emails there are.
    $total_emails count($email_list);
     
    // go through the list and trim off the newline character.
    for ($counter=0$counter<$total_emails$counter++) {
       
    $email_list[$counter] = trim($email_list[$counter]);
       }
     
    // implode the list into a single variable, put commas in, apply as $to value.
    $to implode(",",$email_list);

    $subject "BOLLETTINO Angeli per un giorno";
    $message "<html><body>

    ciao mondo</p></body></html>"
    ;
    $headers  'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $headers .= 'From: [email]bollettino@xxxxx.it[/email]' "\r\n";
    $headers "From: [email]bollettino@axxxxxxxxxxxxxxxx.it[/email]";
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

    if ( 
    mail($to,$subject,$message,$headers) ) {
       echo 
    "The email has been sent!";
       } else {
       echo 
    "The email has failed!";
       }
    ?>
    ma continua ad arrivarmi anonima. non cpaisco dove sbaglio. non è che mi potresti poostare il codice completo? grazie mille.
    P.S. lo script non lo sto usando su altervista al momento ma su aruba.
    grazie ciao

  7. #7
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    356
    Codice PHP:
    $headers .= 'From: [email]bollettino@xxxxx.it[/email]' "\r\n";
    $headers "From: [email]bollettino@axxxxxxxxxxxxxxxx.it[/email]"
    perchè lo metti due volte??
    e inoltre al secondo non c'è \r\n alla fine...
    Jekkil

  8. #8
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    84
    Codice PHP:
    <?php
    // read the list of emails from the file.
    $email_list file("elist.txt");
     
    // count how many emails there are.
    $total_emails count($email_list);
     
    // go through the list and trim off the newline character.
    for ($counter=0$counter<$total_emails$counter++) {
       
    $email_list[$counter] = trim($email_list[$counter]);
       }
     
    // implode the list into a single variable, put commas in, apply as $to value.
    $to implode(",",$email_list);

    $subject "BOLLETTINO Angeli per un giorno";
    $message "<html><body>

    ciao mondo</p></body></html>"
    ;
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers  'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $headers 'From: [email]bollettino@axxxxxxxxxxx.it[/email]' "\r\n";


    if ( 
    mail($to,$subject,$message,$headers) ) {
       echo 
    "The email has been sent!";
       } else {
       echo 
    "The email has failed!";
       }
    ?>
    ho messo così ma ora non va, non mi arriva neanche l'email, non è che potresti correggermelo postandomi il codice completo? te ne sarei molto grato
    graxzie
    ciao

  9. #9
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    356
    Codice PHP:
    $headers  'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $headers .= 'From: [email]bollettino@xxxxx.it[/email]' "\r\n";
    $headers "From: [email]bollettino@axxxxxxxxxxxxxxxx.it[/email]";
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n"
    ma soprattutto, alcune righe non hanno il punto per concatenare le stringhe...
    quindi è come se ci fossero solo le ultime due istruzioni...
    Jekkil

  10. #10
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    356
    $headers deve essere un'unica stringa concatenata...quindi dopo la prima istruzione $headers =, devi mettere $headers .= se no non concatena...
    Jekkil

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.