I am writing an application When email server received an email, to run PHP script in order to replace the mail "from address" with random generated email address as from address.
Basically, email server receives an email, need to identify specific domain(***@xyz.com) and if the domain is matching, need to replace the "from address" with random generated email address by the php code.
For the moment I have figure out that best way is to use the postfix(SMTP) and dovecot(pop3) mail servers, since postfix mail server is allowing to run php script after mail is received by the server. Because postfix smtp server allows to execute php code after receiving an email to server.
as research I have used below link explanation to start my work. https://thecodingmachine.io/triggering-a-php-script-when-your-postfix-server-receives-a-mail
But when I add that code as explained, I cannot restart the Postfix server.
I appreciate if anyone can support with a proper solution to my problem like any approach to get in to there.