Search code examples
cakephp-3.0mailer

CakePHP, overwrite recipient setted


I have a website done with cakephp 3.x to test, I have imported all data from old website and same time user emails. I need to test it with some colleagues but I want that all email in output will go to online one recipient (our company mail). A way to do is putting conditions in all function in each mailers, but there is a way to overwrite recipient before send? Like an event "beforeSend" or similar? Thanks


Solution

  • Thanks to Greg
    There isn't a built-in method, I did a Trait to overwrite the setTo, setCc and setBcc function.
    Trait check in config file if enabled or not.