0
我m curruntly migrating oracle schema to postgresql 9.5 . I
m使用Ora2pg,它爲我轉換了一個函數,負責發送郵件到pgplsql。我的代碼:postgresql中的UTL_SMTP
CREATE OR REPLACE FUNCTION Control_Reports_Pg.send_error_mail (P_Str text,
P_Function_Name text) RETURNS VOID AS $body$
DECLARE
V_Mail_Sender varchar(100) :=
'<[email protected]>';
V_Mail_Recipients varchar(100) :=
'<[email protected]>';
V_Mail_Subject varchar(250):='Error in
'||C_Package_Name||'.'||P_Function_Name;
V_Conn UTL_SMTP.CONNECTION;
BEGIN
V_Conn := Sa_Mail_Api_Pg.Begin_Mail(
Sender => V_Mail_Sender,
Recipients => V_Mail_Recipients,
Subject=>V_Mail_Subject,
Mime_Type => 'text/html; charset=windows-1255');
Sa_Mail_Api_Pg.Write_Mb_Text(
Conn => V_Conn,
Message => P_Str);
Sa_Mail_Api_Pg.End_Mail(Conn => V_Conn);
PERFORM
UTL_FILE.PUT_LINE(current_setting('Control_Reports_Pg.G_Log_File_Type');
END;
$body$
LANGUAGE PLPGSQL
SECURITY DEFINER
;
,但我發現了一個錯誤:
ERROR: schema "utl_smtp" does not exist
LINE 28: V_Conn UTL_SMTP.CONNECTION;
有任何UTL_SMTP
包/模式,我可以導入?通過postgresql
發送郵件需要做什麼修改?
[pgsmtp(https://pgxn.org/dist/pgsmtp/)例如發送郵件。 PostgreSQL是一個DBMS,不是電子郵件客戶端,但它可以使用各種[過程語言](https://www.postgresql.org/docs/current/static/xplang.html)無限擴展。但在開始之前閱讀[this](https://stackoverflow.com/a/12003516/593144)。 – Abelisto