Re: sending mail from Postgres

From: Jeremy Drake <jeremyd(at)apptechsys(dot)com>
To: Aftab Alam <aalam(at)tatashare(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: sending mail from Postgres
Date: 2005-12-28 04:30:15
Message-ID: Pine.LNX.4.63.0512272019240.15097@garibaldi.apptechsys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-hackers pgsql-patches

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:

> Hi there,
>
> How can i send mail form postgresql.
>
> any suggestion.
>
> thanx & regards
> aftab
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>

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

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Christopher Browne 2005-12-28 04:33:07 Re: Online backup vs Continuous backup
Previous Message Aftab Alam 2005-12-28 03:22:42 sending mail from Postgres

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Browne 2005-12-28 04:33:07 Re: Online backup vs Continuous backup
Previous Message Bruce Momjian 2005-12-28 04:00:20 Re: Missing DATE selectivity

Browse pgsql-patches by date

  From Date Subject
Next Message Christopher Browne 2005-12-28 04:33:07 Re: Online backup vs Continuous backup
Previous Message Bruce Momjian 2005-12-28 03:46:28 Re: BUG #2129: dblink problem