Re: the feasibility of sending email from stored procedure in Postgres - Mailing list pgsql-general

From Christopher Browne
Subject Re: the feasibility of sending email from stored procedure in Postgres
Date
Msg-id d6d6637f0802150631h505931eby2aa7f75e9fe2d3d7@mail.gmail.com
Whole thread Raw
In response to the feasibility of sending email from stored procedure in Postgres  (hewei <heweiweihe@gmail.com>)
Responses Re: the feasibility of sending email from stored procedure in Postgres
List pgsql-general
On 2/14/08, hewei <heweiweihe@gmail.com> wrote:
> Can send email from stored procedure in Postgres?

In principle, yes, using one of the "untrusted" stored function
languages.  pl/perl, pl/sh, pl/python, and such.

I wouldn't do things that way...

I would instead queue messages (or suitable information about them) in
a table, and have a process outside PostgreSQL periodically poll for
them.  There are several benefits to that approach:

1.  You're not pushing error handling of email problems inside the
PostgreSQL back end.  That could be rather risky.

2.  You're not spawning an MTA connection every time you submit a
message.  This could be rather expensive.

In contrast, the "poll a queue" approach lets something completely
external deal with email problems.  And it should be able to submit
multiple messages more or less at once, which should improve
efficiency rather a lot; no need to open up sockets to port 25 a whole
bunch of times...
--
http://linuxfinances.info/info/linuxdistributions.html
"The definition of insanity is doing the same thing over and over and
expecting different results." -- assortedly attributed to Albert
Einstein, Benjamin Franklin, Rita Mae Brown, and Rudyard Kipling

pgsql-general by date:

Previous
From: Tomás Di Doménico
Date:
Subject: Re: Trying to understand encoding.
Next
From: "Phoenix Kiula"
Date:
Subject: Re: Are indexes blown?