Re: Sending email from PL/pgSQL - Mailing list pgsql-novice

From Andreas Kretschmer
Subject Re: Sending email from PL/pgSQL
Date
Msg-id 20130828165652.GA26856@tux
Whole thread Raw
In response to Sending email from PL/pgSQL  (Jack Kaufman <jack.kaufman@sanmina.com>)
Responses Re: Sending email from PL/pgSQL
List pgsql-novice
Jack Kaufman <jack.kaufman@sanmina.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°


pgsql-novice by date:

Previous
From: Alan Hodgson
Date:
Subject: Re: Sending email from PL/pgSQL
Next
From: Kevin Hunter Kesling
Date:
Subject: Re: cross-table constraints?