Trigger PHP from alias with qmail

1k views Asked by At

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.

3

There are 3 answers

0
DetDev On BEST ANSWER

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.

0
Barry On

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.

1
user2430266 On

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.