I have a simple architecture at the moment which looks a little something like this:
User sends Email > Postfix > Procmail > PHP Script > Write to third party Web App
The third party web app happens to be a CMS (I am using its API to create records).
The problem that I am having is that users are sending Emails to the user of "support", where as the Web Server runs on the user "apache".
Because of this setup, all the attachments are being created with the user of "support" and the group "support", however I need them to actually be created as "apache:apache" (so that the CMS can read and display these attachments in it's templates).
I understand PHP has functions chown and chmod, however when trying to run these commands even from the command line, I am unable to handover ownership of the files to the user "apache".
Is there an easy way for me to preserve file permissions based on the create directory? Is this something I need to change from php.ini? Or perhaps I need to re-think the architecture?
Thanks for the help!