Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-docspgsql-hackerspgsql-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

pgsql-docs by date

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

pgsql-hackers by date

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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group