I would like to run a script when an email is received. I added this line to /etc/aliases

myuser: "|/home/myuser/mailer.rb"

When I send an email to myuser@domain, I see permission denied error in the maillog.

Aug 12 14:17:59 stag postfix/local[29300]: E5B8F67024F: to=, relay=local, delay=1596, delays=1596/0.01/0/0.02, dsn=4.3.0, status=deferred (temporary failure. Command output: local: fatal: execvp /home/myuser/mailer.rb: Permission denied )

The permission on mailer.rb is 755. Why would I get a permission denied error?

I would appreciate any help. Thanks!


Can you get as far as the script with that user? I'm guessing it can't open the user's home directory. Try
sudo -u postfix /home/myuser/mailer.rb to confirm this. To fix it, which distro are you running?

  • When I try running as postfix, I get the error "Sorry, user myuser is not allowed to execute "/home/myuser/mailer.rb" as postfix. I am running Red Hat Enterprise Linux Server release 5.4 (Tikanga) – maheshmurthy Aug 12 '10 at 19:42
  • Are you sure it's not "sorry user postfix is not allowed to execute"? Try doing sudo -u postfix ls -la /home/myuser/mailer.rb to see if it can even find it. If not: setfacl -m user:postfix:r-x /home/myuser If it can, but just can't execute it, try: setfacl -m user:postfix:r-x /home/myuser/mailer.rb – James L Aug 12 '10 at 19:49
  • Yeah, even I noticed that error message and am confused. It is "myuser not allowed to execute as postfix". I can't do anything as sudo -u postfix. It asks for password and when I enter the myuser password, it gives me the same not allowed to execute message. – maheshmurthy Aug 12 '10 at 20:03
  • Sorry this is my oversight, the sudo command I gave you needs to be run as root. – James L Aug 12 '10 at 20:38
  • So, I found out that it was running as user "nobody". So, I executed setfacl on user "nobody" and it works now! Thanks for the help! – maheshmurthy Aug 12 '10 at 21:24

Is SELinux enabled? You can check that with getenforce. If it returns enforcing, then SELinux is on and can cause that kind of problems. If you don't need SELinux, you may temporarily disable it with setenforce 0 and see if it cures the problem.

If it does, you may permanently disable SELinux by modifying file /etc/selinux/config.

  • Looks like it is disabled $ /usr/sbin/getenforce Disabled – maheshmurthy Aug 12 '10 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.