1

I am using the contact form plugin in Craft CMS 3. I want to add the afterSend event. Where should I add the file to write the code for the afterSend event?

1

You should add it to custom-made module.

Go to https://pluginfactory.io/ to generate your module scaffolding (you don't need to select any additional components like models, variables etc for this), then install it accoding to instructions in readme file.

After that, attach to event in module init() function:

    public function init()
    {
        parent::init();
        self::$instance = $this;
        Event::on(Mailer::class, Mailer::EVENT_AFTER_SEND, function(SendEvent $e) {
           // custom logic...
        });
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.