After using
puts $mySock "rcpt cc: myemail@domain.com"
I am able to send mail as Cc: also.
Thanks
Dinesh Pandey
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