views:

48

answers:

1

I'm tring to handle errors from bounced email. This is my scenario:

  • Send emails out with Pear Mail() +Mail_Mime();
  • Set 'Return-Path'and 'Return-Recipient-To' to get errors in "[email protected]";

Now using a class mentioned here (http://stackoverflow.com/questions/1097382/how-to-handle-mail-delivery-errors-with-php) I want to read the mail folder containing the delivery error messages.

The path is like "/home/domain-name/mail/domain-name.com/bounce/new/" but when i run the class i get the error "failed to open dir: Permission denied..."

Dir /mail/ is 770 chmod, /domain-name/ is 750 chmod, /bounce/ is 750 chmod, /new/ is 700 chmod. Think i should change permission, but dont know how and if this could make less secure the mail folder.

+2  A: 

I would guess that your webserver is running as apache or nobody which is not the owner of the mail folder (so it would therefore have 0 as the permission - which is nothing)

You either need to run the webserver as that user (I wouldnt do that) or change the permission on the folder to allow the webserver to read the folder

webdestroya
@webdestroya: Thanks! How i can change permission on the folder? Do you mean chmod?
Luciano
@Luciano - Yes, `chmod` will work. You need to add `+r` and `+x` to the folder
webdestroya
@webdestroya: I've changed chmod to 755 but still get the same error... not expert with apache server. :|
Luciano
@Luciano - You probably need to recursively apply it `chmod -R 755 /path/to/folder`
webdestroya
@webdestroya: I changed recursively chmod, but now have a problem reading the delivery file. It's set to chmod 600, if i change it manually at 644 works fine, but i need to do it in my script and php-chmod doesn't works.
Luciano
@Luciano - Then it seems you'll have to change the mail server that writes that file. Beyond that, i'm not sure
webdestroya
I managed to make it work! Hell yesss. :) First reading the mail folder thru ftp_nlist() and listing files with a foreach. Then copy each file to /bounced/ folder into my root with ftp_fget(). Finally read reports using the class bounce_handler and writing result on db. As i will finish this script i'll update the question with my rought solution.
Luciano