UTL_SMTP in postgresql
NickName:JeyJ Ask DateTime:2017-07-05T23:06:43

UTL_SMTP in postgresql

Im curruntly migrating oracle schema to postgresql 9.5 . Im using Ora2pg and it converted for me one function which is reponsible for sending mail to pgplsql. My code :

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
  ;

But i'm getting the next error :

ERROR:  schema "utl_smtp" does not exist
LINE 28:      V_Conn                             UTL_SMTP.CONNECTION;

Is there any UTL_SMTP package / schema that i can import ? What changes i need to do in order to send mail via postgresql ?

Copyright Notice:Content Author:「JeyJ」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/44929948/utl-smtp-in-postgresql

More about “UTL_SMTP in postgresql” related questions

UTL_SMTP in postgresql

Im curruntly migrating oracle schema to postgresql 9.5 . Im using Ora2pg and it converted for me one function which is reponsible for sending mail to pgplsql. My code : CREATE OR REPLACE FUNCTION

Show Detail

Debugging with Oracle's utl_smtp

A client of mine uses Oracle 9i's utl_smtp to send mails out notifications to managers when their employees have made travel requests and they woul like quite a few changes made to the mailouts don...

Show Detail

Sending email from oracle apex UTL_SMTP with smtp server credentials

Is there a way to send email using UTL_SMTP method by providing smtp server credentials which is not localhost. i.e. SMTP service is running somewhere else but is not https secures, i want to use

Show Detail

UTL_SMTP utility in Adaptive Server Enterprise database

What is the counterpart of Oracle's utl_smtp utility in Adaptive Server Enterprise database. Thank you

Show Detail

How to attach an Excel file to an UTL_SMTP package in Oracle for sending an Email

Can Anyone provide the code for Attaching an Excel to an UTL_SMTP mail package in Oracle.

Show Detail

UTL_SMTP insufficient privilege

I am trying to send mail using oracle utl_smtp and have the below error : environment : Oracle cloud os : linux DB : "Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production Versi...

Show Detail

Sending multiple emails using UTL_SMTP in oracle

I am trying to write a procedure which send emails from Oracle DB using UTL_SMTP functions. Its working fine if I am only sending one email address but if I am passing multiple emails as comma or

Show Detail

ORACLE 11g UTL_SMTP and "Reply To" / "On Behalf Of"

We are using the UTL_SMTP package in ORACLE 11g to send emails from our system on behalf of the users. It all gets sent out through a common SENDER account to validate against the SMTP server. ...

Show Detail

PL/SQL character buffer overflow in UTL_SMTP

I have a PL/SQL sproc which sends an email, with addressee and such as parameters. We recently migrated it, to a new environment, and switched it from using an internal mail server to using Office ...

Show Detail

Oracle PL/SQL UTL_SMTP raising a 501 5.1.7 Bad sender address syntax

When I send e-mails using the package UTL_SMTP I am getting this error when executing the comand UTL_SMTP.MAIL: 501 5.1.7 Bad sender address syntax I am passing olny the e-mail as second parameter.

Show Detail