Send email from PostgreSQL, may I ?

Started by Gerson Machadoover 19 years ago7 messagesgeneral
Jump to latest
#1Gerson Machado
gersonamach@yahoo.com.br

I need send email directly from PG with on function, where locate this ?

Tks

---------------------------------
Yahoo! Search
M�sica para ver e ouvir: You're Beautiful, do James Blunt

#2A. Kretschmer
andreas.kretschmer@schollglas.com
In reply to: Gerson Machado (#1)
Re: Send email from PostgreSQL, may I ?

am Fri, dem 27.10.2006, um 11:11:01 +0000 mailte Gerson Machado folgendes:

I need send email directly from PG with on function, where locate this ?

There isn't such a function. But you can use untrusted languages to do
this. I'm using plsh for this and send emails with my favorite MUA mutt.

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

#3Devrim GÜNDÜZ
devrim@gunduz.org
In reply to: Gerson Machado (#1)
Re: Send email from PostgreSQL, may I ?

Hi,
On Fri, 2006-10-27 at 11:11 +0000, Gerson Machado wrote:

I need send email directly from PG with on function, where locate
this ?

You can send e-mails via pltclu or plperlu, more is also possible.

http://sourceforge.net/projects/pgmail/ <- This is tcl one.

plperlu one is attached. I don't remember where I got this one.

Regards,
--
The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/

Attachments:

sendmail.plperlutext/plain; charset=UTF-8; name=sendmail.plperluDownload
#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Gerson Machado (#1)
Re: Send email from PostgreSQL, may I ?

Gerson Machado wrote:

I need send email directly from PG with on function, where locate this ?

Typically this is bad idea. Better save the email info on a table and
fire a NOTIFY. An external daemon would be listening to that
notification, and send the email from the data in the table, which it
can subsequently delete or mark as used.

This is also better because you have a chance to retry if your SMTP is
down or whatever. If you fail to send the mail in a trigger or
function, you have no way to wait 10 minutes without clogging your
application.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#5Taras Kopets
tkopets@gmail.com
In reply to: Alvaro Herrera (#4)
Re: Send email from PostgreSQL, may I ?

Hi!

Gerson Machado wrote:

I need send email directly from PG with on function, where locate this ?

Alvaro Herrera wrote:

Typically this is bad idea. Better save the email info on a table and

fire a NOTIFY. An external daemon would be listening to that
notification, and send the email from the data in the table, which it
can subsequently delete or mark as used.

If you still want to send e-mails directly from PG, you can try to use my
function based on pgmail which will allow you to send e-mail using
mailservers
which require authorization and analyze relpy from smtp to be sure your
e-mail is sent (look in attachment). You will need to install pltclu first.

PS: Maybe anyone knows how to send a unicode characters in e-mail using Tcl?

Taras Kopets

Attachments:

my_tcl_sendmail.sqltext/sql; charset=ANSI_X3.4-1968; name=my_tcl_sendmail.sqlDownload
#6Tony Caduto
tony_caduto@amsoftwaredesign.com
In reply to: Alvaro Herrera (#4)
Re: Send email from PostgreSQL, may I ?

Typically this is bad idea. Better save the email info on a table and
fire a NOTIFY. An external daemon would be listening to that
notification, and send the email from the data in the table, which it
can subsequently delete or mark as used.

This is also better because you have a chance to retry if your SMTP is
down or whatever. If you fail to send the mail in a trigger or
function, you have no way to wait 10 minutes without clogging your
application.

I wouldn't go so far as to say it's a bad idea(it really depends on what
you need to do).
I have been using a plperl based solution in a heavily used client
server application.

We don't send the emails via a trigger though, strictly initiated by a
procedure call from the client. Never had one single problem doing it
this way.

You wouldn't clog your application if you initiate the process through a
separate connection to the server which is initiated from a thread.

--
Tony Caduto
AM Software Design
http://www.amsoftwaredesign.com
Home of PG Lightning Admin for Postgresql
Your best bet for Postgresql Administration

#7Joshua D. Drake
jd@commandprompt.com
In reply to: Tony Caduto (#6)
Re: Send email from PostgreSQL, may I ?

Tony Caduto wrote:

Typically this is bad idea. Better save the email info on a table and
fire a NOTIFY. An external daemon would be listening to that
notification, and send the email from the data in the table, which it
can subsequently delete or mark as used.

This is also better because you have a chance to retry if your SMTP is
down or whatever. If you fail to send the mail in a trigger or
function, you have no way to wait 10 minutes without clogging your
application.

I wouldn't go so far as to say it's a bad idea(it really depends on what
you need to do).

It certainly can be a very bad idea. Especially if the client that fires
the process is a web server.

Joshua D. Drake

--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate