'How to send async emails server side in next.js

I am working on a simple next.js app similar to a forum, where people can upload a media item and other people can send a comment to this item. Now I would like to send an email to all the people that sent a comment, to notify when a new comment was submitted.

I would like to know if I can dispatch an event and trigger this send email operation somewhere server side, in order not to make the user wait for all the emails to be sent.

The app is already configured to use AWS SES so I just need to know how to trigger an event server side, or if I should just trigger an async operation and how. Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source