| From: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: Sending email from PL/pgSQL |
| Date: | 2013-08-28 16:56:52 |
| Message-ID: | 20130828165652.GA26856@tux |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
Jack Kaufman <jack(dot)kaufman(at)sanmina(dot)com> wrote:
> Would someone provide an example of how to send email from a PL/pgSQL function?
You can't do that. Pl/pgsql is a so called 'trusted language', you can't
call functions outside the database. What you can do:
- fill a table with tasks (address, content and so) and use, for
instance, a cron-job to retrieve data from this table, send the mail
and delete the record
- use untrusted languages like pl/perlU, pl/sh or other
- use a listen/notify - mechanism to do that
Within a pl/pgsql - function all is in a transaction - but you can't fetch
back an email.
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Kevin Hunter Kesling | 2013-08-28 17:59:21 | Re: cross-table constraints? |
| Previous Message | Alan Hodgson | 2013-08-28 16:55:28 | Re: Sending email from PL/pgSQL |