duanqin7791 2013-07-04 09:44
浏览 81
已采纳

php邮件功能内容布局

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

  • 写回答

1条回答 默认 最新

  • dtz33344 2013-07-04 10:02
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀