使用 qmail 从别名触发 PHP

发布于 2024-12-10 12:12:41 字数 1427 浏览 0 评论 0 原文

我已经很接近了,我发现的所有示例都有帮助。我可以从终端运行 PHP,但无法从收到的电子邮件中运行脚本。

我缺少的部分是让传入的电子邮件连接到 qmail 别名

以获取上下文。我使用的电子邮件位于

[email protected]

服务器的根目录中我创建了一个别名,

/var/qmail/alias

命名

.qmail-bb3k

该别名在 .qmail-bb3k 文件中

|/var/www/vhosts/thatdomain.com/cgi-bin/scrapeAttachment.php

,我运行该文件直接

./.qmail-bb3k: line 1: syntax error near unexpected token `|'

将电子邮件发送到 [email protected] 不执行任何操作,电子邮件成功通过,但 PHP 脚本从未运行。

每次修改脚本时,qmail都会重新启动(不确定是否有必要)。

我可以通过修改 .qmail-bb3k 脚本来运行 PHP 脚本

php /var/www/vhosts/thatdomain.com/cgi-bin/scrapeAttachment.php

,该脚本在从终端运行时有效,我们已经知道这一点,但四倍检查不会损害

我一直引用的链接

http://www.evolt.org/incoming_mail_and_php

http://www.geeksdrafts.net/blog/2011/02/11/sample-qmail-files/

有足够多的活动部件我不确定是否存在简单的语法问题或 bash 和 php 范围之外的问题。

如有任何建议,我们将不胜感激

I'm pretty close here, all the examples I have found have been helpful. I can run the PHP from the terminal but cannot get the script to run from a received email.

The part I am missing is getting the incoming email to connect to the qmail alias

for context. the email I am using is

[email protected]

in the root of the server I created an alias in

/var/qmail/alias

the alias is named

.qmail-bb3k

in the .qmail-bb3k file i have

|/var/www/vhosts/thatdomain.com/cgi-bin/scrapeAttachment.php

running that file directly gives me

./.qmail-bb3k: line 1: syntax error near unexpected token `|'

sending an email to [email protected] does nothing, the email makes it through, but the PHP script is never run.

everytime the script is modified, qmail is restarted (not sure if that is necessary.)

i can get the PHP script to run by modifying the .qmail-bb3k script to

php /var/www/vhosts/thatdomain.com/cgi-bin/scrapeAttachment.php

which works when run from the terminal, which we already knew, but quadruple checking doesn't hurt

the links that I've been referencing

http://www.evolt.org/incoming_mail_and_php

http://www.geeksdrafts.net/blog/2011/02/11/sample-qmail-files/

There is enough moving parts that i'm not sure if there is a simple syntax issue or something outside the scope of the bash and php.

any suggestions would be greatly appreciated

t.o.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

唯憾梦倾城 2024-12-17 12:12:41

DetDev,回复有点晚了,但您是否意识到每次 MediaTemple 运行 Plesk 更新时,您在此文件夹中创建的 .qmail 文件都会被删除?

/var/qmail/mailnames/thatdomain.com/user

当我注意到我的电子邮件管道设置大约每月发生一次故障并且看到 .qmail 文件为空时,我发现了这个问题。

不幸的是,除了手动重新创建文件之外,我还没有找到解决方案。当我无法修复服务器并且消息丢失时,这是相当麻烦的。

DetDev, this is a bit of a late reply but did you realize that the .qmail file you created in this folder will be erased every time MediaTemple runs a Plesk update?

/var/qmail/mailnames/thatdomain.com/user

I discovered this problem when I noticed that my email piping setup broke about once a month and saw that the .qmail file was empty.

Unfortunately I have not found an solution to this other than re-creating the file manually. It's quite a hassle when I'm not available to fix the server and messages are lost.

谜兔 2024-12-17 12:12:41

因此,这不是上述具体问题的答案,而是该问题试图实现的目标的替代解决方案。

仅供参考,这是在 Plesk 上,MT 作为托管提供商。不同的服务器,不同的设置YMMV...

简短版本。 我没有使用别名

/var/qmail/alias

并在那里创建 .qmail-user,而是转到

/var/qmail/mailnames/thatdomain.com/user

该文件夹​​下的特定用户是 .qmail 文件。当我修改它时,结果是成功的。

感谢@Dagon 让我退后一步并在更高级别进行调试!

干杯,

So this is not an answer to the specific question above it is an alternative solution to what this question was trying to accomplish.

FYI, This is on Plesk with MT as the hosting provider. Different servers, different settings YMMV...

Short version. Instead of using an alias under

/var/qmail/alias

and creating the .qmail-user there I just went to the specific user under

/var/qmail/mailnames/thatdomain.com/user

in that folder is a .qmail file. when I modified that, the outcome is a success.

Thanks to @Dagon for getting me top step back and debug at a higher level!

Cheers,

t.o.

缱倦旧时光 2024-12-17 12:12:41

我使用 chmod -i .qmail 解决了 plesk 更新覆盖 .qmail 文件的问题,因此该文件无法更改。自动更新时没有出现任何问题。

i got around plesk updates overwriting the .qmail file using chmod -i .qmail so the file can't be changed. didn't cause any issues when updating automatically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文