Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YjbRQ-0004e2-9P for pgsql-general@arkaria.postgresql.org; Sat, 18 Apr 2015 22:42:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YjbRP-0000hd-Mt for pgsql-general@arkaria.postgresql.org; Sat, 18 Apr 2015 22:42:23 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YjbRN-0000dw-Rz; Sat, 18 Apr 2015 22:42:22 +0000 Received: from mail-by2on0671.outbound.protection.outlook.com ([2a01:111:f400:fc0c::671] helo=na01-by2-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YjbRJ-0007rg-S0; Sat, 18 Apr 2015 22:42:19 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jim.Nasby@bluetreble.com; Received: from decina.attlocal.net (2602:306:ce8b:3460:c5fa:ceb:7ddc:1dcb) by BY2PR11MB0680.namprd11.prod.outlook.com (0.163.111.22) with Microsoft SMTP Server (TLS) id 15.1.136.25; Sat, 18 Apr 2015 22:42:10 +0000 Message-ID: <5532DDB9.4070507@BlueTreble.com> Date: Sat, 18 Apr 2015 17:42:01 -0500 From: Jim Nasby User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: "David G. Johnston" , Suresh Raja CC: "pgsql-general@postgresql.org" , "pgsql-sql@postgresql.org" Subject: Re: [SQL] function to send email with query results References: In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [2602:306:ce8b:3460:c5fa:ceb:7ddc:1dcb] X-ClientProxiedBy: BLUPR07CA0052.namprd07.prod.outlook.com (10.255.223.165) To BY2PR11MB0680.namprd11.prod.outlook.com (25.163.111.22) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR11MB0680; X-Microsoft-Antispam-PRVS: X-Forefront-Antispam-Report: BMV:1; SFV:NSPM; SFS:(10009020)(979002)(6009001)(51704005)(377454003)(479174004)(53754006)(24454002)(33656002)(19580395003)(83506001)(42186005)(59896002)(2950100001)(53416004)(80316001)(19580405001)(106356001)(40100003)(23676002)(86362001)(87266999)(50986999)(64126003)(76176999)(15975445007)(47776003)(77156002)(65806001)(62966003)(87976001)(65956001)(122386002)(54356999)(50466002)(4001350100001)(65816999)(92566002)(46102003)(4001540100001)(5001770100001)(36756003)(3826002)(85282002)(336755003)(18886065003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR11MB0680; H:decina.attlocal.net; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(5002010); SRVR:BY2PR11MB0680; BCL:0; PCL:0; RULEID:; SRVR:BY2PR11MB0680; X-Forefront-PRVS: 0550778858 Received-SPF: None (protection.outlook.com: bluetreble.com does not designate permitted sender hosts) X-OriginatorOrg: bluetreble.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2015 22:42:10.2963 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR11MB0680 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On 4/18/15 12:52 AM, David G. Johnston wrote: > On Friday, April 17, 2015, Suresh Raja > 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