dongxiaoshe0737 2013-08-14 22:39
浏览 38
已采纳

为什么不在此电子邮件中解释HTML?

I'm running a website loccaly useing WAMP and have installed Test Mail Server Tool to act as a mail server (all it does is saves the messages as .eml files). I've tried opening the messages with Lotus Notes and gmail (web interface) and both do not interpret the HTML, for example instead of having a clickable link they have <a href='localhost'>click here</a> Did I make a mistake with the headers?

Here is the code I am using

$to = 'bepusslai@fakeinbox.com';
$from = 'From: tester1@localhost.com';
$subject = 'this is a test';
$message = '<html><head></head><body>Hello. Please follow <a href="http://localhost/proc.php?uid=45ab3">this link</a> to activate your account.'
    ."r
".'<a href="http://localhost/proc.php?uid=45ab3"><img src="images/ActivateButton.gif" alt="activate button" />
    </body></html>';
$headers = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; utf-8' . "
";
$headers .= 'From: testk1@localhost.com' . "
";
mail($to, $subject, $message, $from, $headers);

By the way, I was stuck not having a mail server since WAMP doesn't come with one and I red on another question someone recommended Test Mail Server Tool. I'm open to using a different one because it doesn't seem popular.

  • 写回答

2条回答 默认 最新

  • duananyu9231 2013-08-14 22:46
    关注

    If you refer to the docs and examples in the docs, you will see that the From information is not a separate argument to mail() but is included with the additional-headers information.

    bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

    Remove your $from argument from the call to mail().

    mail($to, $subject, $message, $headers);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)