From: | "Dinesh Pandey" <dpandey(at)secf(dot)com> |
---|---|
To: | "'PostgreSQL'" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: send mail from Postgres using PLTCLU language. |
Date: | 2005-04-15 14:40:06 |
Message-ID: | 20050415144247.8DEE05402D@svr1.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
After using
puts $mySock "rcpt cc: myemail(at)domain(dot)com"
I am able to send mail as Cc: also.
Thanks
Dinesh Pandey
_____
From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-owner(at)postgresql(dot)org]
On Behalf Of Dinesh Pandey
Sent: Friday, April 15, 2005 6:18 PM
To: 'PostgreSQL'
Subject: [SQL] send mail from Postgres using PLTCLU language.
How to send mail from Postgres using PLTCLU language.
I am able to send mail, but I want to know how to add "Cc" option also.
(Program attached below)
How to add "Cc" (Right now containd "From", "To", "Subject" and "Message").
----------------------------------------------------------------
CREATE or REPLACE FUNCTION pgmail(text, text, text, text) returns int4 as '
set mailfrom $1
set mailto $2
set mailsubject $3
set mailmessage $4
set myHost "localhost"
set myPort 25
set mySock [socket $myHost $myPort]
set toemailaddress_start [string first "<" $mailto]
if {$toemailaddress_start != -1} {
set toemailaddress_finish [string first ">" $mailto]
set toemailaddress_start [expr $toemailaddress_start + 1]
set toemailaddress_finish [expr $toemailaddress_finish - 1]
set toemailaddress [string range $mailto $toemailaddress_start
$toemailaddress_finish]
} else {
set toemailaddress $mailto
}
set fromemailaddress_start [string first "<" $mailfrom]
if {$fromemailaddress_start != -1} {
set fromemailaddress_finish [string first ">" $mailfrom]
set fromemailaddress_start [expr $fromemailaddress_start + 1]
set fromemailaddress_finish [expr $fromemailaddress_finish - 1]
set fromemailaddress [string range $mailfrom $fromemailaddress_start
$fromemailaddress_finish]
} else {
set fromemailaddress $mailfrom
}
fileevent $mySock writable [list svcHandler $mySock]
fconfigure $mySock -buffering none
puts $mySock "helo 127.0.0.1"
gets $mySock name
puts $mySock "mail from: $fromemailaddress"
gets $mySock name
puts $mySock "rcpt to: $toemailaddress"
gets $mySock name
puts $mySock "data"
gets $mySock name
puts $mySock "To: $mailto"
puts $mySock "From: $mailfrom"
puts $mySock "Subject: $mailsubject"
puts $mySock ""
puts $mySock "$mailmessage"
puts $mySock "."
gets $mySock name
close $mySock
return 1'
language 'pltclu';
--------------------------------
Regards
Dinesh Pandey
From | Date | Subject | |
---|---|---|---|
Next Message | Markus Schaber | 2005-04-15 16:22:32 | Re: row-attribute in EXPLAIN-output doesn't match count(*) |
Previous Message | TJ O'Donnell | 2005-04-15 12:52:52 |