From: | Louis-David Mitterrand <cunctator(at)apartia(dot)ch> |
---|---|
To: | Tulio Oliveira <mestredosmagos(at)marilia(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Trigger sending an eMail |
Date: | 2001-03-04 12:22:04 |
Message-ID: | 20010304132204.E15968@apartia.ch |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Feb 26, 2001 at 06:09:58PM -0300, Tulio Oliveira wrote:
> How is the best form of a trigger send an email ?
>
> I'll need make the trigger in C or the plpgsql has any mail function ?
#if !defined(_PATH_SENDMAIL)
# define _PATH_SENDMAIL "/usr/lib/sendmail"
#endif /*SENDMAIL*/
#define MAILCMD _PATH_SENDMAIL
#define MAILARGS "%s -Fpostgres -oem -t"
/* send notification e-mail
*/
static int sendmail(char * mailto, char * subject, char * mess) {
register FILE *mail;
char * mailcmd;
asprintf(&mailcmd, MAILARGS, MAILCMD);
if (!(mail = popen(mailcmd, "w"))) {
elog(ERROR, "Couldn't run command %s", MAILCMD);
(void) _exit(ERROR_EXIT);
}
free(mailcmd);
fprintf(mail, "From: Apartia Auction Daemon <root(at)apartia(dot)com>\n");
fprintf(mail, "To: ldm(at)apartia(dot)com\n");
fprintf(mail, "Subject: %s\n", subject);
fprintf(mail, "User-Agent: to %s\n", mailto);
fprintf(mail, "\n");
fprintf(mail, mess);
fprintf(mail, "\n.\n");
return pclose(mail);
}
--
-= this .sig is not funny =-
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Richardson | 2001-03-04 16:14:49 | CREATE INDEX function limitation |
Previous Message | Louis-David Mitterrand | 2001-03-04 12:18:38 | Re: avoiding endless loop in an UPDATE trigger |