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条)

报告相同问题?

悬赏问题

  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像