运行电子邮件列表脚本时来自 Cron 守护程序的额外电子邮件
我有一个 PHP 脚本,每两周向订阅者发送一次提醒。每次发送电子邮件时,它也会发送一封来自“Cron Daemon”的电子邮件。当我第一次编写脚本时,它没有发送这封电子邮件,但现在它发送了。我对此有几个问题。
这封电子邮件的内容是这样的:
Set-Cookie: PHPSESSID=((random letters and numbers here)); path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-type: text/html
- 这封电子邮件是什么意思?
- 为什么要发送这封电子邮件?
- 有没有办法阻止票据发送这封电子邮件?
I have a PHP script that sends out a bi-weekly reminder to subscribers. Each time it sends out the email it also sends out an email that comes in from "Cron Daemon." When I first wrote the script, it didn't send this email, but now it does. I have a few questions about this.
This is what the email says:
Set-Cookie: PHPSESSID=((random letters and numbers here)); path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-type: text/html
- What does this email mean?
- Why is this email being sent?
- Is there a way to stop the scrip from sending this email?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Cron 读取执行命令的 stdout/stderr,如果写入了内容,则 cron 发送一封电子邮件。
我猜 php 可执行文件被编译为“cgi”或“fcgi”,因此它默认发出这些标头。
为了解决这个问题,你显然有三种可能的解决方案:
> /dev/null 2>&1
附加到你的 cron 命令)。MAILTO=""
(请参阅 本页)。Cron reads the stdout/stderr of the command that gets executed, if something is written then cron sends an E-Mail.
I guess the php-executable is compiled as "cgi" or "fcgi" so it emits those headers by default.
To solve this you have apparently three possible solutions:
> /dev/null 2>&1
to your cron command).MAILTO=""
(see this page).我的猜测是你的 PHP 脚本正在向输出渲染一些内容。如果有任何内容被渲染,cron 会将其转发到默认管理员电子邮件。
有两种解决方案:
1) 修复 PHP 脚本,使其根本不输出任何内容。这有时比看起来更困难,尤其是对于不平凡的脚本。
2) 防止 cron 脚本永远有输出。此方法的缺点是当脚本失败时您也不会收到通知。要停止输出,请使用类似以下内容:
My guess is your PHP script is rendering something to the output. If anything gets rendered at all, cron forwards that to the default administrator email.
There's two solutions to this:
1) Fix your PHP script to not output anything at all. This is sometimes harder than it would seem, especially for non-trivial scripts.
2) Prevent the cron script from ever having an output. The drawback to this method is you won't get a notice when the script fails, either. To stop the output, use something like this: