douken1726 2015-07-29 14:17
浏览 46
已采纳

无法在WordPress中发送多个PHP mail()标头

I am using Gravity Forms to handle forms and after the form submission I have coded a simple mail() function to send an email to the user. The headers work fine individually:

$headers = 'From: MyName
';

// or 

$headers .= 'Content-type: text/html; charset=iso-8859-1
';

mail('me@gmail.com', 'My Subject', 'My Content', $headers);

but together in either order there is an issue"

$headers = 'From: MyName
'; // works fine
$headers .= 'Content-type: text/html; charset=iso-8859-1
'; // In this case the body is not rendered as HTML
// or
$headers = 'Content-type: text/html; charset=iso-8859-1
'; // renders as HTML
$headers .= 'From: MyName
'; // This now gives "unknown sender"

Any ideas?

  • 写回答

1条回答 默认 最新

  • duanbei3747 2015-07-29 15:30
    关注

    Line breaks need to be double-quoted in order for " " to be respected. As the headers are currently defined, ' ' is being treated as literal text, not a line break.

    $headers = "From: MyName
    ";
    $headers .= "Content-type: text/html; charset=iso-8859-1
    "; 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 cplex运行后参数报错是为什么
  • ¥15 之前不小心删了pycharm的文件,后面重新安装之后软件打不开了
  • ¥15 vue3获取动态宽度,刷新后动态宽度值为0
  • ¥15 升腾威讯云桌面V2.0.0摄像头问题
  • ¥15 关于Python的会计设计
  • ¥15 聚类分析 设计k-均值算法分类器,对一组二维模式向量进行分类。
  • ¥15 stm32c8t6工程,使用hal库
  • ¥15 找能接spark如图片的,可议价
  • ¥15 关于#单片机#的问题,请各位专家解答!
  • ¥15 博通raid 的写入速度很高也很低