dongye9071 2010-02-09 23:32 采纳率: 0%
浏览 58
已采纳

Postfix搞砸了电子邮件标题!

I've set up a local dev environment on snow leopard, and have set postfix up to send email via my isp mail server.

I eventually got postfix to work after much frustration, but now when my emails send the header information is bunged up!

I'm using the following php code:

$email = "me@mydomain";
$subject = "Email tester";
$body = "Simple test";
$header = "From: me@mydomain 
";
$header .= "MIME-VERSION: 1.0
";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$phpversion = phpversion();
$header .= "X-Mailer: PHP v$phpversion
";
mail($email,$subject,$body,$header);

echo "message sent!";

The To: and Subject: headers display as they should, in the header!, but the rest display in the email body. This makes the email look like the from field in email client is empty.

I've tried a variety of php scripts, some very simple, but its the same thing, headers always displaying in the email body.

I'm thinking it could be a postfix problem, but not sure, anyone encountered this type of problem before?

  • 写回答

3条回答 默认 最新

  • douyi4297 2011-05-16 20:10
    关注

    Use PHP_EOL instead of in *additional_headers*, i.e. $header in your example. PHP_EOL will substitute the newline correspondingly to the OS you are running on.

    Also, message should contain LN only i.e. . This is accordingly to PHP documentation. Each line should be separated with a LF ( ). Lines should not be larger than 70 characters.

    Make sure you meet both of criterias in your script - I've tried to achieve it and finally got it working with the default configuration of Postfix.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘