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
    "; 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥115 用Java解决探地雷达dzt文件的解析过程
  • ¥20 有关神经网络这道(b)determine the parameters of neural network
  • ¥25 annaconda jvpyter
  • ¥20 来一个会抓包app支付接口的
  • ¥30 vivado2017.4的sdk打不开
  • ¥50 matlab,文献复现
  • ¥20 寻找Flink CDC指导,有偿咨询
  • ¥15 cruise如何仿真不同温度下车辆的经济性?
  • ¥20 扑克牌游戏的完整代码
  • ¥88 求帮安装Python架构的vnpy