Fonction mail php la bonne format de header

Résolu
safa778 Messages postés 23 Date d'inscription   Statut Membre Dernière intervention   -  
safa778 Messages postés 23 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

ma fonction mail en php me permet de recuperer les données de l'utilisteur de formulaire de contact avec une piece jointe mais quand j'ai de récuperer les données de l'email sous format html ça marche pas et la piece jointe ne s'ouvre pas voila mon headers code

$headers = "MIME-Version: 1.0\r\n"; 
        $headers.= "From: Et\r\n"; 
        $headers.= "Reply-To: TA" . "\r\n";
        $headers.= "MIME-Version: 1.0" . $passage_ligne;
        $headers.= 'Content-type: text/html; charset=iso-8859-1 \r\n';
        $headers.= 'Content-Type: multipart/mixed; boundary='.$boundary .' '. $passage_ligne;


je dois enlever le type html pour que la piece jointe s'ouvre si nn avec seulement multipart mixed les balise html serons visible quans je recu les emails
A voir également:

1 réponse

jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   4 752
 
Bonjour,

Exemple
 $filename = 'myfile';
    $path = 'your path goes here';
    $file = $path . "/" . $filename;

    $mailto = 'mail@mail.com';
    $subject = 'Subject';
    $message = 'My message';

    $content = file_get_contents($file);
    $content = chunk_split(base64_encode($content));

    // a random hash will be necessary to send mixed content
    $separator = md5(time());

    // carriage return type (RFC)
    $eol = "\r\n";

    // main header (multipart mandatory)
    $headers = "From: name <test@test.com>" . $eol;
    $headers .= "MIME-Version: 1.0" . $eol;
    $headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol;
    $headers .= "Content-Transfer-Encoding: 7bit" . $eol;
    $headers .= "This is a MIME encoded message." . $eol;

    // message
    $body = "--" . $separator . $eol;
    $body .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $eol;
    $body .= "Content-Transfer-Encoding: 8bit" . $eol;
    $body .= $message . $eol;

    // attachment
    $body .= "--" . $separator . $eol;
    $body .= "Content-Type: application/octet-stream; name=\"" . $filename . "\"" . $eol;
    $body .= "Content-Transfer-Encoding: base64" . $eol;
    $body .= "Content-Disposition: attachment" . $eol;
    $body .= $content . $eol;
    $body .= "--" . $separator . "--";

    //SEND Mail
    if (mail($mailto, $subject, $body, $headers)) {
        echo "mail send ... OK"; // or use booleans here
    } else {
        echo "mail send ... ERROR!";
        print_r( error_get_last() );
    }

1
safa778 Messages postés 23 Date d'inscription   Statut Membre Dernière intervention  
 
mille merci :D
0