Visualizzazione dei risultati da 1 a 3 su 3

Discussione: mail non html

  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2009
    Messaggi
    115

    mail non html

    Come mai quando invio una mail dal mio server di prova al mio client "windows mail", ricevo il testo, compreso il codice html?
    Windows mail è configurato per ricevere html.
    Vi ringrazio.


    <?php
    $to_address = $_POST['to_address'];
    $from_address = $_POST['from_address'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];

    $headers = array();
    $headers[] = 'MIME-Version: 1.0';
    $headers[] = 'Content_type: text/html; charset=iso-8859-1';
    $headers[] = 'Content-Transfer-Encoding: 7bit';
    $headers[] = 'From: ' . $from_address;
    ?>
    <html>
    <head>
    <title>Mail Sent!</title>
    </head>
    <body>
    <?php
    $success = mail($to_address, $subject, $message, join("\r\n", $headers));
    if ($success) {
    echo '<h1>Congratulation!</h1>';
    echo '

    The following message has been sent:

    ';
    echo 'To: ' . $to_address . '
    ';
    echo 'From: ' . $from_address . '
    ';
    echo 'Subject:' . $subject . '
    ';
    echo 'Message:</p>';
    echo nl2br($message);
    } else {
    echo '

    There was an error sending your message.</p>';
    }
    ?>
    </body>
    </html>

  2. #2
    Hai fatto solo un piccolo errore di sintassi: si scrive Content-type, non Content_type

    Ecco il codice corretto:
    Codice PHP:
    <?php
    $to_address 
    $_POST['to_address'];
    $from_address $_POST['from_address'];
    $subject $_POST['subject'];
    $message $_POST['message'];

    $headers = array();
    $headers[] = 'MIME-Version: 1.0';
    $headers[] = 'Content-type: text/html; charset=iso-8859-1';
    $headers[] = 'Content-Transfer-Encoding: 7bit';
    $headers[] = 'From: ' $from_address;    
    ?>
    <html>
    <head>
    <title>Mail Sent!</title>
    </head>
    <body>
    <?php
    $success 
    mail($to_address$subject$messagejoin("\r\n"$headers));
    if (
    $success) {
    echo 
    '<h1>Congratulation!</h1>';
    echo 
    '

    The following message has been sent: 

    '
    ;
    echo 
    '[b]To:[/b] ' $to_address '
    '
    ;
    echo 
    '[b]From:[/b] ' $from_address '
    '
    ;
    echo 
    '[b]Subject:[/b]' $subject '
    '

    echo 
    '[b]Message:[/b]</p>';
    echo 
    nl2br($message);
    } else {
    echo 
    '

    [b]There was an error sending your message.[/b]</p>'
    ;
    }    
    ?>
    </body>
    </html>

  3. #3
    Utente di HTML.it
    Registrato dal
    Dec 2009
    Messaggi
    115
    Ti ringrazio!!

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.