【发布时间】:2012-08-17 03:30:47
【问题描述】:
我使用代码发送电子邮件:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
但我得到了:
sendmail:致命:chdir /Library/Server/Mail/Data/spool:没有这样的文件或目录
而且我不知道如何添加附件,重要的是我需要指定附件的 Content-Type,有人可以帮助我吗?
谢谢!
【问题讨论】:
-
您的服务器(Mac?)配置错误,您必须先修复该问题,然后才能发送邮件。然后考虑使用 PHPmailer 或 Swiftmailer 发送电子邮件 - 仅使用 mail() 发送附件非常痛苦且容易出错。
-
@MarcB 自己处理附件和各种哑剧组绝对是一种有趣的体验;-)
标签: php sendmail content-type