How to "feed to program"

6 posts / 0 new
Last post
#1 Mon, 02/18/2013 - 03:54
dotcom22

How to "feed to program"

hello

I need to execute a PHP script when a message come to inbox of a specific email address.

I tried to do that using ALIA but this is not possible due to some permission problem.

I asked my provider who privately asked the author of Virtualmin and his answer was this:

This is unfortunately expected and un-avoidable - when you create an alias like that, the command is run by the mail server (Postfix) which doesn't have permissions to run scripts as other users.

One work-around would be to have the mail go to a Virtualmin user who had a procmail rule setup to run whatever command you want, which will run with the user's privileges.

So I created my specific Email address "feed-test@mydomain.com" and I tried to setup a "Procmail Mail Filter" rule. I choose on the drop-down menu the option "feed to program" Then I set the URL of my script who look like:

/home/myusername/domains/mydomain.com/public_html/mailtest.php

But when I send a message to "feed-test@mydomain.com" the script is not executed even if the mail is delivered in the mailbox.

I tried to play with some Options in "Procmail Mail Filter" but no change and the script is always not executed.

Actually my script contain only few line of code planned for send a test email to a specific email address. If I type the URL of the script in my browser, the script is well executed...

My goal right now was to test "feed to program" feature for see if is well possible to fire a script by email. Then later I will need to fetch the email content and process it by my script.

Somebody can tell me why the script is not executed ?

thank

Mon, 02/18/2013 - 08:53
andreychek

Howdy,

If you look in the procmail logs, in /var/log/procmail.log, do you see any errors being generated when your script is running?

Also, if you look in /home/myusername/, do you see a .procmailrc file? If so, you may want to verify that it contains something telling your system to execute that script when an email arrives?

-Eric

Mon, 02/18/2013 - 14:22
dotcom22

thank for your reply..

In logs I get this:

Folder: /home/myusername/domains/mysite.com/homes/emailtosms/Maildir 1215 Time:1361176681 From:any@email.com To:emailtosms@mysite.com User:emailtosms-mysite.com Size:1266 Dest:/home/myusername/domains/mysite.com/homes/emailtosms/Maildir/new/1361176680.23798_1.mu11.provider.com Mode:None

and I don't have any file.procmailrc in /home/myusername

So it seem defintely something is wrong in my setup. I attached a screenshot of my setup. I miss something ??

Mon, 02/18/2013 - 15:32
andreychek

Oh I see, so the .procmailrc file should actually be here in this directory:

/home/myusername/domains/mysite.com/homes/emailtosms/

Mon, 02/18/2013 - 17:16
dotcom22

Ok I got the file and inside I have this:

:0wf | /home/myusername/domains/mydomain.com/public_html/mailtest.php

So something more must be present in this file ?

Sat, 09/20/2014 - 13:58
Topic locked