Subject: sending mail from Postgres

From: "Aftab Alam" <[email-masked]>
Date: Wed, 28 Dec 2005 08:52:41 +0530

Hi there,

How can i send mail form postgresql.

any suggestion.

thanx & regards
aftab

---

From: Jeremy Drake <[email-masked]>
Date: Tue, 27 Dec 2005 20:30:15 -0800 (PST)

Code from perl cookbook, wrapped in plperlu wrapper

not very portable, Net::SMTP would probably be better, and result in more
portable perl code.

Didn't test this - but it is copied straight from perl cookbook via
google: http://www.unix.org.ua/orelly/perl/cookbook/ch18_04.htm

CREATE OR REPLACE FUNCTION send_email(from_address text, to_address text,
	subject text, body text) RETURNS void AS $$

use Mail::Mailer;
my ($from_address, $to_address, $subject, $body) = @_;

my $mailer = Mail::Mailer->new("sendmail");
$mailer->open({ From    => $from_address,
                To      => $to_address,
                Subject => $subject,
              })
    or die "Can't open: $!";
print $mailer $body;
$mailer->close();

$$ LANGUAGE plperlu VOLATILE STRICT;

On Wed, 28 Dec 2005, Aftab Alam wrote:

> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>

-- 
Don't steal; thou'lt never thus compete successfully in business.  Cheat.
		-- Ambrose Bierce

---

From: "Pavel Stehule" <[email-masked]>
Date: Wed, 28 Dec 2005 06:20:11 +0100

Hello,

it depend on your possibilities. Simply, use PL/Perl or PL/sh.

Regards
Pavel Stehule

or use PgSendMail
http://sourceforge.net/project/showfiles.php?group_id=35804
>TIP 6: explain analyze is your friend

_________________________________________________________________
Citite se osamele? Poznejte nekoho vyjmecneho diky Match.com. 
http://www.msn.cz/

---

From: David Fetter <[email-masked]>
Date: Wed, 28 Dec 2005 20:53:15 -0800

> How can i send mail form postgresql.

Generally, it is a better idea either to poll your PostgreSQL database
and send mail based on that, or use LISTEN/NOTIFY, rather than
directly sending mail from your database.

Cheers,
D
-- 
David Fetter [email-masked] http://fetter.org/
phone: +1 415 235 3778

Remember to vote!