Search Postgresql Archives

Re: the feasibility of sending email from stored procedure in Postgres

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/14/08, hewei <heweiweihe@xxxxxxxxx> 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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux