How to call the sendEmail program from Linux from within Oracle

2

I know that Oracle has a package for this ( UTL_SMTP ), however I would like to use the Linux < strong> sendmail .

Does anyone have any code examples or do you know where the Oracle documentation is on this?

    
asked by anonymous 28.05.2014 / 21:07

1 answer

1

There is unofficial documentation on this page :

And I want to put the example they provide here because I believe it is a great example:

The easiest way to send an email is through the following procedure:

    CREATE OR REPLACE PROCEDURE send_mail (p_to        IN VARCHAR2,
                                           p_from      IN VARCHAR2,
                                           p_message   IN VARCHAR2,
                                           p_smtp_host IN VARCHAR2,
                                           p_smtp_port IN NUMBER DEFAULT 25)
    AS
      l_mail_conn   UTL_SMTP.connection;
    BEGIN
      l_mail_conn := UTL_SMTP.open_connection(p_smtp_host, p_smtp_port);
      UTL_SMTP.helo(l_mail_conn, p_smtp_host);
      UTL_SMTP.mail(l_mail_conn, p_from);
      UTL_SMTP.rcpt(l_mail_conn, p_to);
      UTL_SMTP.data(l_mail_conn, p_message || UTL_TCP.crlf || UTL_TCP.crlf);
      UTL_SMTP.quit(l_mail_conn);
    END;
    /

The code below shows how to call such a procedure.

    BEGIN
      send_mail(p_to        => '[email protected]',
                p_from      => '[email protected]',
                p_message   => 'Isso é apenas um Olá Mundo.',
                p_smtp_host => 'smtp.nsa.com');
    END;
    /

EDITED:

The only way to call external programs / processes is by package:

dbms_scheduler , whose documentation is specified in this link.

    
29.05.2014 / 08:41