0

Deal all, I want to send an email notification directly form Oracle plsql using outer mail server (External hosting), I've searched on the internet and found a useful way to send an email using Oracle UTL_smtp package, but it requires to have the mail server locally not remotely.

CREATE OR REPLACE PROCEDURE SEND_MAIL (
msg_to varchar2,
msg_subject varchar2,
msg_text varchar2 )
IS
c utl_smtp.connection;
rc integer;
msg_from varchar2(50) := 'Oracle9.2';
mailhost VARCHAR2(30) := '127.0.0.1'; -- local database host

BEGIN
c := utl_smtp.open_connection(mailhost, 25); -- SMTP on port 25
utl_smtp.helo(c, mailhost);
utl_smtp.mail(c, msg_from);
utl_smtp.rcpt(c, msg_to);

utl_smtp.data(c,'From: Oracle Database' || utl_tcp.crlf ||
'To: ' || msg_to || utl_tcp.crlf ||
'Subject: ' || msg_subject ||
utl_tcp.crlf || msg_text);
utl_smtp.quit(c);

EXCEPTION
WHEN UTL_SMTP.INVALID_OPERATION THEN
dbms_output.put_line(' Invalid Operation in Mail attempt
using UTL_SMTP.');
WHEN UTL_SMTP.TRANSIENT_ERROR THEN
dbms_output.put_line(' Temporary e-mail issue - try again');
WHEN UTL_SMTP.PERMANENT_ERROR THEN
dbms_output.put_line(' Permanent Error Encountered.');
END;

So, how can this be done using external domain!! Please help..

  • "but it requires to have the mail server locally" - why are you saying that? The configuration option is right there in the code you pasted – Mat Nov 23 '17 at 07:53
  • Possible duplicate of [Send email in oracle 10g](https://stackoverflow.com/questions/13244712/send-email-in-oracle-10g) – F0XS Nov 23 '17 at 08:04
  • The issue is security, as always. Connecting the database server to external servers usually requires infrastructure configuration and so negotiating with the gatekeepers of that configuration. – APC Nov 23 '17 at 08:09
  • It can be done using APEX_MAIL https://stackoverflow.com/questions/38052894/apex-mail-send-function-not-working-though-its-not-giving-any-error – Abdullah Zabarah Nov 25 '17 at 05:58
  • https://stackoverflow.com/questions/38052894/apex-mail-send-function-not-working-though-its-not-giving-any-error This topic helps you to do the procedure. – Abdullah Zabarah Nov 25 '17 at 06:00

0 Answers0