Re: a trigger that sends an email - Mailing list pgsql-interfaces

From Tom Lane
Subject Re: a trigger that sends an email
Date
Msg-id 26948.955032666@sss.pgh.pa.us
Whole thread Raw
In response to RE: a trigger that sends an email + returning multiple records  ("Oscar Serrano" <oserra@fondos.net>)
Responses Re: a trigger that sends an email  (Craig Orsinger <orsingerc@epg-gw1.lewis.army.mil>)
List pgsql-interfaces
"Oscar Serrano" <oserra@fondos.net> writes:
>>>> I thing I need to create a trigger. And I thing I need to create a
>>>> function that sends an email.
>>>> Is it possible?
>>>> May I do the function that sends the email in Perl?

I don't think you can do this directly from a trigger, unless you want
to add the mail-sending function as a C extension to the backend.
You'll run into security restrictions.  All of the higher-level trigger
programming languages we offer are "trusted", which means you can't do
anything that would affect files or programs outside the database.
Sending email is right out.

Of course there's nothing wrong with a C-coded function; the system's
full of them ;-).  But you might want to think about other ways.

One possibility is to set up an always-running application that connects
to the database and then just sits there waiting for records to be added
to the table, then sends the email when that happens.  You could use a
NOTIFY command (executed by a trigger on the table) to wake up the app
when something happens, so that it doesn't need to take up CPU time
checking the table unnecessarily.
        regards, tom lane


pgsql-interfaces by date:

Previous
From: The Hermit Hacker
Date:
Subject: Ksql Interface ...
Next
From: Richard
Date:
Subject: Re: a trigger that sends an email + returning multiple records