Re: Email and Postgres

From: Philip Hallstrom <philip(at)adhesivemedia(dot)com>
To: Ian Kulmatycki <ikulmatycki(at)movement-inc(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Email and Postgres
Date: 2000-11-07 03:58:58
Message-ID: Pine.BSF.4.21.0011061957080.1418-100000@oddjob.adhesivemedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I don't think so (when I looked anyway), but I hacked the PHP mail
function and compiled it as a user function... It doesn't do any checking
(never got around to it) but it works. Someday I'll do that...

The first comment is what I used to compiled it... you'll need to tweak
some of the options to point to the right place. I don't remember the
exact syntax to add it to the database, but it's in the manual and was
easy... you might also needto change the path to sendmail...

--------------------------
/*
gcc -I/local/src/postgresql-7.0/src/include -I/local/src/postgresql-7.0/src/backend -O2 -m486 -pipe -Wall -Wmissing-prototypes -Wmissing-declarations -I/local/src/postgresql-7.0/src/interfaces/libpq -I/local/src/postgresql-7.0/src/include -fpic -DPIC -c -o send_email.o send_email.c
ld -x -shared -o send_email.so send_email.o
rm send_email.o
*/

#include <stdio.h>
#include "postgres.h"
#include "utils/builtins.h"

int send_email(text *from, text *to, text *subject, text *body) {
int success;
FILE *fd;

fd = popen("/usr/sbin/sendmail -oi -t", "w");

if( fd ) {
fprintf(fd, "From: %s\n", textout(from));
fprintf(fd, "To: %s\n", textout(to));
fprintf(fd, "Subject: %s\n", textout(subject));
fprintf(fd, "\n");
fprintf(fd, "%s", textout(body));

success = pclose(fd);
}else {
success = 0;
}

return(success);
}

On Mon, 6 Nov 2000, Ian Kulmatycki wrote:

> Hi all,
> Does anyone know if you can send email using pgsql and triggers or some
> other way?
> Thanks
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Ian Kulmatycki 2000-11-07 07:12:36 Uploading oid over the internet
Previous Message Sandeep Joshi 2000-11-07 00:11:35 embedded