简体   繁体   中英

php mail function content layout

From a html form a text is stored in a database. With the following code I tried to mail that text to a reciepant:

$recipient = $emailadres;
    $subject = 'xxxx';
    $header = 'From: xxxx <xxx@xxxxxxxxx.nl>';
    if ($aanhef == 'Dhr.') {
        $geslacht = 'heer';
    }
    elseif ($aanhef == 'Mevr.') {
        $geslacht = 'mevrouw';
    }
    else {
        $geslacht = 'heer/mevrouw';
    }
    $mail_body = $bevestiging;
    $mail_body = str_replace('#geslacht#', $geslacht, $mail_body);
    $mail_body = str_replace('#achternaam#', $achternaam, $mail_body);
    mail($recipient, $subject, $mail_body, $header);

in the variable mail_body the content of the mail is stored, after that gender and last name in the content are replaced. This php code works. However, if we looked at the recieved mail all the enters filled in in the HTML form become two enters, in other words the whole layout of the email has changed, when I look into the database the text is there in normal layout, no double enters ect. But if I put in the text manually in the database it works normal. Is it possible that in the database a hidden html layout is stored? Or is it something else

Change your $header variable to this:

$header ="Content-type: text/html; FROM: xxxx <xxx@xxxxxxxxx.nl>";

and the sent email will be displayed as HTML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM