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

From Jack Kaufman
Subject Re: Sending email from PL/pgSQL
Date
Msg-id CAM=VM82AJR2zixToTHDPgQ7z=hGfxvu5UU9LuO48Me7yrpozyQ@mail.gmail.com
Whole thread Raw
In response to Re: Sending email from PL/pgSQL  (Andreas Kretschmer <akretschmer@spamfence.net>)
Responses Re: Sending email from PL/pgSQL
List pgsql-novice

Alan and Andreas,

Thank you!  You both said essentially the same thing:  That I will need to write the email attributes to a table and have a script on the server call the email client.  So that is the way I will proceed.  Thank you both for your replies and for helping me move along toward solving this problem.

Take care, Jack

On Wed, Aug 28, 2013 at 12:56 PM, Andreas Kretschmer <akretschmer@spamfence.net> wrote:

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°


--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice



--
Jack Kaufman
MDS Application Devl (US)
Sanmina-SCI Corporation - Owego site
Email: jack.kaufman@sanmina.com
Skype: jack_kaufman_sanm
607-723-0507

CONFIDENTIALITY
This e-mail message and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail message, you are hereby notified that any dissemination, distribution or copying of this e-mail message, and any attachments thereto, is strictly prohibited.  If you have received this e-mail message in error, please immediately notify the sender and permanently delete the original and any copies of this email and any prints thereof.
ABSENT AN EXPRESS STATEMENT TO THE CONTRARY HEREINABOVE, THIS E-MAIL IS NOT INTENDED AS A SUBSTITUTE FOR A WRITING.  Notwithstanding the Uniform Electronic Transactions Act or the applicability of any other law of similar substance and effect, absent an express statement to the contrary hereinabove, this e-mail message its contents, and any attachments hereto are not intended to represent an offer or acceptance to enter into a contract and are not otherwise intended to bind the sender, Sanmina Corporation (or any of its subsidiaries), or any other person or entity.

pgsql-novice by date:

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