From: | "Dinesh Pandey" <dpandey(at)secf(dot)com> |
---|---|
To: | "'PostgreSQL'" <pgsql-sql(at)postgresql(dot)org> |
Subject: | send mail from Postgres using PLTCLU language. |
Date: | 2005-04-15 12:47:49 |
Message-ID: | 20050415125113.C3A4053A95@svr1.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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 | TJ O'Donnell | 2005-04-15 12:52:52 | |
Previous Message | Sean Davis | 2005-04-15 10:12:11 | Re: Combining values in a column |