pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedC function to send an email in PostgreSQL
2+ messages / 2 participants
[nested] [flat]
* C function to send an email in PostgreSQL
@ 2001-09-19 10:42 Miguel González <iafmgc@unileon.es>
0 siblings, 1 reply; 2+ messages in thread
From: Miguel González @ 2001-09-19 10:42 UTC (permalink / raw)
To: pgsql-php
Dear all,
I want to create a function to send an email. I pass to the function two arguments: the email to send, and the text
to send.
First, I tried with pointers to char. It worked when I just create a
function called "sendemail()" with no arguments and set inside the text and
the email arguments.
When I read some more documentation about how to use strings in PostgreSQL,
I discovered that I have to use the text type in my C program I just try it
but
although it worked before, now I doesnt work.
This is what I have tried:
#include <stdio.h>
#include "postgres.h"
int sendemail(text *email,text *message)
{
char string_tosend [300];
sprintf(string_tosend,"echo \"%s\" >/tmp/mailtmp.txt
\n",VARDATA(message));
system(string_tosend);
sprintf(string_tosend,"mail -s \"message from PostgreSQL\" %s
</tmp/mailtmp.txt \n",VARDATA(message));
system(string_tosend);
system("rm /tmp/mailtmp.txt");
return 0;
}
and then in the back-end of PostgreSQL and I declared
CREATE FUNCTION sendemail(text,text)
RETURNS int4
AS '/home/postgres/libpginvuimail.so'
LANGUAGE 'c';
and then SELECT sendemail('postgres','test from backend');
and it didnt work. What am I doing wrong?
I have being testing and I guess is something to do with the text data type
and how to use it within a C program.
Many thanks in advance
Miguel
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: C function to send an email in PostgreSQL
@ 2001-09-19 11:32 Vince Vielhaber <vev@michvhf.com>
parent: Miguel González <iafmgc@unileon.es>
0 siblings, 0 replies; 2+ messages in thread
From: Vince Vielhaber @ 2001-09-19 11:32 UTC (permalink / raw)
To: Miguel González <iafmgc@unileon.es>; +Cc: pgsql-php
On Wed, 19 Sep 2001, [iso-8859-1] Miguel González wrote:
> Dear all,
>
> I want to create a function to send an email. I pass to the function two arguments: the email to send, and the text
> to send.
Have you seen pgMail? http://sourceforge.net/projects/pgmail/
Vince.
--
==========================================================================
Vince Vielhaber -- KA8CSH email: vev@michvhf.com http://www.pop4.net
56K Nationwide Dialup from $16.00/mo at Pop4 Networking
Online Campground Directory http://www.camping-usa.com
Online Giftshop Superstore http://www.cloudninegifts.com
==========================================================================
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-09-19 11:32 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-09-19 10:42 C function to send an email in PostgreSQL Miguel González <iafmgc@unileon.es>
2001-09-19 11:32 ` Vince Vielhaber <vev@michvhf.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox