From: | Luis A(dot) Zevallos Cárdenas <lzevallos(at)lobosistemas(dot)com> |
---|---|
To: | posgres <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Funcion pgmail |
Date: | 2009-06-05 16:49:09 |
Message-ID: | ae5556ce0906050949o50e66844gf5939c8213017485@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Hola a todos
Tengo un problema con una funcion pgmail
*********************************FUNCION*********************************
CREATE OR REPLACE FUNCTION pgmail(text, text, text, text)
RETURNS integer AS
$BODY$
set mailfrom $1
set mailto $2
set mailsubject $3
set mailmessage $4
set myHost "<ENTER YOUR MAILSERVER HERE>"
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 <ENTER YOUR DATABASESERVER HERE>"
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$BODY$
LANGUAGE 'pltclu' VOLATILE
COST 100;
ALTER FUNCTION pgmail(text, text, text, text) OWNER TO lzevallos;
*************************************************************************************
select pgmail('Send From <lzevallos(at)lobosistemas(dot)com>','Send To <
lzevallos(at)lobosistemas(dot)com>','test mail','Test');
ERROR
**************************************************************************************
ERROR: couldn't open socket: host is unreachable
CONTEXT: couldn't open socket: host is unreachable
while executing
"socket $myHost $myPort"
(procedure "__PLTcl_proc_522212" line 9)
invoked from within
"__PLTcl_proc_522212 {Send From <lzevallos(at)lobosistemas(dot)com>} {Send To <
lzevallos(at)lobosistemas(dot)com>} {test mail} Test"
in PL/Tcl function "pgmail"
********** Error **********
ERROR: couldn't open socket: host is unreachable
Estado SQL:XX000
Contexto:couldn't open socket: host is unreachable
while executing
"socket $myHost $myPort"
**************************************************************************************
Alguien que podria ayudarme
Saludos y gracias
--
Luis Zevallos
DBA Administrador de DB & SRVR
Lobo Sistemas S.A.C
tel: +5154958310833
http://www.lobosistemas.com
From | Date | Subject | |
---|---|---|---|
Next Message | Fredy Gonzales P. | 2009-06-05 17:18:44 | RE: [pgsql-es-ayuda] Campos BYTEA a través de ODBC en Linux |
Previous Message | Leonardo Castillo | 2009-06-05 16:35:48 | Campos BYTEA a través de ODBC en Linux |