Hi Tim,
I'm trying to work with UTL_SMTP in order to send emails from database server. I have followed your great articles regarding ACLs. These are the steps I have followed in order to make this work. As yo can see almost at the bottom of my message I'm able to make utl_mail.send works but when trying UTL_SMTP I'm receiving no errors but I'm not receiving an expected email either. Looking forward for your response. Thanks!
Oracle version: 11.2.0.2.0
OS: Windows Server 2003 Standard Edition
conn / as sysdba
alter system set smtp_out_server = '10.101.19.135' scope=spfile;
GRANT CREATE PROCEDURE, DROP ANY PROCEDURE TO USER;
GRANT EXECUTE ON UTL_TCP TO USER;
GRANT EXECUTE ON UTL_SMTP TO USER;
GRANT EXECUTE ON UTL_MAIL TO USER;
GRANT EXECUTE ON DBMS_NETWORK_ACL_ADMIN TO USER;
grant execute on SYS.utl_http to USER;
GRANT EXECUTE ON SYS.UTL_MAIL TO USER;
==============
= CREATE ACL =
==============
begin
dbms_network_acl_admin.create_acl (
acl => 'utl_mail.xml',
description => 'Allow mail to be sent',
principal => 'USER',
is_grant => TRUE,
privilege => 'connect'
);
end;
/
begin
dbms_network_acl_admin.add_privilege (
acl => 'utl_mail.xml',
principal => 'USER',
is_grant => TRUE,
privilege => 'resolve'
);
commit;
end;
/
begin
dbms_network_acl_admin.assign_acl (
acl => 'utl_mail.xml',
host => '10.101.19.135',
lower_port => 25,
upper_port => 25);
commit;
end;
/
conn user/user
-- THIS PROCEDURE WORKS
begin
utl_mail.send(
sender => 'jesus.carranza@celanese.com.mx',
recipients => 'jesus.carranza@celanese.com.mx',
message => 'Hello World'
);
end;
/
-- THIS IS NOT WORKING
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;
/
BEGIN
send_mail(p_to => 'user@domain.com',
p_from => 'user@domain.com',
p_message => 'This is a test message.',
p_smtp_host => '10.101.19.135');
END;
/
PL/SQL procedure successfully completed.
But no email received...