I have a shell script that I want to send the same email as in the controller. The controller action uses the SwiftMailer component. However, Shells can’t call controller actions, so I’m looking for a way to modularize this email-sending code so that it can be used by both my shell and my controller.
Ideally I would put this email-sending code in the afterSave, but once again, components can’t be used in models.
Any ideas? Thanks!
Well, this may not be the greatest idea, but you did say “Any ideas?” 🙂
Probably the most reasonable course of action would be to extract the mail-sending code in a separate library (in the Lib folder) and then change your component and shell to use it.
Whether this is possible with your code is the real question, which I guess only you can answer. If you don’t know, you’ll just have to try.
In any case, good luck!