邮件:无法打开流:权限被拒绝?
我在使用 php 发送邮件时收到此警告 警告:邮件(1)[function.mail]:无法打开流:/home/...中的权限被拒绝
- 使用 ssmtp 和 gmail 作为 smtp
- PHP 5.3.1
- 日志中没有任何内容(没有错误)
- 邮件到达
- 目的地文件的权限是rwxrxrx
权限被拒绝什么?
甚至调用像
mail("[email protected]", " 这样简单的东西主题”、“正文”);
我仍然收到此警告
I get this warning sending mails with php
Warning: mail(1) [function.mail]: failed to open stream: Permission denied in /home/...
- using ssmtp and gmail as smtp
- PHP 5.3.1
- nothing in the logs (no errors)
- the mail gets to destination
- the permissions of the files are rwxrxrx
Permission denied to what?
Even calling something as simple as
mail("[email protected]", "subject", "body");
I still getting this warning
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题是网络服务器用户无法写入和/或读取邮件日志文件。对于正确的配置:
1) 创建用于电子邮件日志记录的文件夹和文件。例如:
2) 在 php.ini 中设置日志文件:
3) 在需要时设置该文件夹/文件的所有者和组:
检查所有者和组,
如果需要,更改组(更改 www-data无论您的 Web 服务器的组是什么)
如果需要,请更改所有者(无论您的 Web 服务器的用户是什么,更改 www-data)
The problem is that the webserver user is not able to write and/or read the mail log file. For a propper configuration:
1) create the folder and the file for the email logging. For example:
2) set the logging file in php.ini:
3) set the owner and the group for that folder/file in case needed:
check the owner and the group with
in case needed, change the group (change www-data for whatever your web server's group is)
in case needed, change the owner (change www-data for whatever your web server's user is)
如果你简化一下它有用吗?
如果是这样,那么您就知道邮件有效。
之后,我会删除 $eol 内容,看看是否可以修复它。如果没有,那么我将删除标题块并继续删除内容,直到它开始工作。
Does it work if you simplify it?
If it does, then you know that mail works.
After that, I would remove the $eol stuff and see if that fixes it. If not, then I would remove the header block and keep removing stuff until it starts working.
原来是文件权限问题。但不是在脚本中,而是在目录中。
我运行了 chmod -R 777 * ,警告消失了。经过进一步检查,我发现了一个名为
1
的文件,该文件包含已发送邮件的日志。警告是 php 告诉我他无法打开这个文件
解决方案:
F#$%^% cryptic php error messages
It turns out to be a file permissions problems after all. But not in the scripts, but in the directory.
I ran a
chmod -R 777 *
and the warning went of. upon further examination I found a file called1
, and this file contained a log of the sent mails.The warning was php telling me that he was unable to open this file
Solution:
F#$%^% cryptic php error messages