Thread: function to send email with query results
Hi all:
I'm looking to write a function to send email with result of a query. Is it possible to send email with in a function. Any help is appreciated.
Thanks,
-Suresh Raja
On Friday, April 17, 2015, Suresh Raja <suresh.rajaabc@gmail.com> wrote:
Hi all:I'm looking to write a function to send email with result of a query. Is it possible to send email with in a function. Any help is appreciated.
Yes...though neither the neither the sql nor the plpgsql languages have the necessary language features to do so - you will need to use something like plperlu.
An (not mutually exclusive) alternative is to create an email queue and write an email sending client application to process that queue. The main advantages being loose coupling and the ability to send the emails asynchronously.
David J.
On 4/17/2015 10:30 PM, Suresh Raja wrote: > > I'm looking to write a function to send email with result of a query. > Is it possible to send email with in a function. Any help is > appreciated. I would do that in an application, not a plXXXX sql function. make a query, fetch the results, format them as you see fit for the email and toss it at your language-of-choice's email facility. -- john r pierce, recycling bits in santa cruz
On 4/18/15 12:52 AM, David G. Johnston wrote: > On Friday, April 17, 2015, Suresh Raja <suresh.rajaabc@gmail.com > <mailto:suresh.rajaabc@gmail.com>> wrote: > > Hi all: > > I'm looking to write a function to send email with result of a > query. Is it possible to send email with in a function. Any help > is appreciated. > > > Yes...though neither the neither the sql nor the plpgsql languages have > the necessary language features to do so - you will need to use > something like plperlu. > > An (not mutually exclusive) alternative is to create an email queue and > write an email sending client application to process that queue. The > main advantages being loose coupling and the ability to send the emails > asynchronously. If you go that route you might find LISTEN/NOTIFY useful: http://www.postgresql.org/docs/9.4/static/sql-listen.html -- Jim Nasby, Data Architect, Blue Treble Consulting Data in Trouble? Get it in Treble! http://BlueTreble.com
Using Apache camel
Listen/notify ->PGEvent Component (http://camel.apache.org/pgevent.html) -> Mail Component (http://camel.apache.org/mail.html)
You can also then handle all the exceptions of the email server easily.
On Sun, Apr 19, 2015 at 6:42 AM, Jim Nasby <Jim.Nasby@bluetreble.com> wrote:
On 4/18/15 12:52 AM, David G. Johnston wrote:On Friday, April 17, 2015, Suresh Raja <suresh.rajaabc@gmail.com<mailto:suresh.rajaabc@gmail.com>> wrote:
Hi all:
I'm looking to write a function to send email with result of a
query. Is it possible to send email with in a function. Any help
is appreciated.
Yes...though neither the neither the sql nor the plpgsql languages have
the necessary language features to do so - you will need to use
something like plperlu.
An (not mutually exclusive) alternative is to create an email queue and
write an email sending client application to process that queue. The
main advantages being loose coupling and the ability to send the emails
asynchronously.
If you go that route you might find LISTEN/NOTIFY useful: http://www.postgresql.org/docs/9.4/static/sql-listen.html
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general