Trigger sending an eMail

Started by Tulio Oliveiraabout 25 years ago4 messagesgeneral
Jump to latest
#1Tulio Oliveira
mestredosmagos@marilia.com

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 ?

regards,

Tulio

#2Joseph
lters@mrtc.com
In reply to: Tulio Oliveira (#1)
RE: Trigger sending an eMail

Try pgsendmail.
ftp://ftp.trurl.anything3d.com/pub/Linux/our/pgsendmail-1.1.tar.gz
or
http://ftp.trurl.anything3d.com/Linux/our/pgsendmail-1.1.tar.gz

Joseph Showalter

Show quoted text

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Tulio Oliveira
Sent: Monday, February 26, 2001 4:10 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Trigger sending an eMail

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 ?

regards,

Tulio

#3Louis-David Mitterrand
cunctator@apartia.ch
In reply to: Tulio Oliveira (#1)
Re: Trigger sending an eMail

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@apartia.com>\n");
fprintf(mail, "To: ldm@apartia.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 =-

#4Louis-David Mitterrand
vindex@apartia.ch
In reply to: Louis-David Mitterrand (#3)
Re: Trigger sending an eMail

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@apartia.com>\n");
fprintf(mail, "To: ldm@apartia.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 =-