As the previous answer said, you should think about the question of performance. And by directly answering your question about "Or is this a job for a background service?" I would say it would be advisable to do so, yes.
Think of the problems that could be occasioned if you enter yourself 10 records and suddenly 3 of these email sending processes crash. Or even think of a scenario, if you were using a g-mail SMTP, for example, and this request took about 15 seconds to be solved (as happened to me in some cases). This would definitely affect the performance of your database.
I would think of another question: it is not the responsibility of my database to send an email. So I would do this yes via a command line or, as already suggested, using an application backend to do this.
As I suggested in my comment, I might consider using a TRIGGER to fire a command running in Background, as the link below:
In my humble opinion: I think this kind of thing should be done in the application layer.
First: Do you have a backend for entering the data into the database? I do not know if there is how to do by postgree, but as email usually takes a few seconds to send (if it is SMTP), I would avoid doing this.
– Wallace Maxters
For that is my doubt the question precisely in the delay in sending would delay the CRUD process
– Fabricio
Fabrício, depending on the situation, it is necessary to analyze if Trigger could fire a command line. Then maybe you could use Sendmail.
– Wallace Maxters
When I ask you, what are you wearing?
– Wallace Maxters
@Wallacemaxters is a very useful idea
– Fabricio
Take a look in that stuff
– Wallace Maxters
@Wallacemaxters "What are you using? "?
– Fabricio
OS = Operating system.
– Wallace Maxters
Let’s go continue this discussion in chat.
– Wallace Maxters