24 September, 2008

APEX_MAIL with UTL_TCP under XE database

. 24 September, 2008

If you want to use the features of the UTL_TCP package you need to publish it to your APEX application user. (I tested it under APEX 3.1.2)

How to:

-- sqlplus
GRANT EXECUTE ON "SYS"."UTL_TCP" TO "APEX_USER"

-- sqlplus
create or replace synonym UTL_TCP for SYS.UTL_TCP;

-- an APEX process procedur
-- apex_mail procedure call
apex_mail.send(
p_to => 'user@company.com',
p_from => 'info@company.com',
p_body => 'New message cerated from ' || :p1_user || '.' || utl_tcp.crlf ||
'Description: ' || utl_tcp.crlf || :p1_description,
p_subj => 'New message! ' utl_tcp.crlf);

-- push the e-mail queue for immediate delivery
wwv_flow_mail.push_queue(
P_SMTP_HOSTNAME => 'ip',
P_SMTP_PORTNO => 'port');

Update (08.09.2009):
There was a interesting question about the APEX_MAIL function and pushing the email queue in the Oracle forum which you may be interested on: apex mail - mail queue

3 Comments:

Rodrigo Rojas Moraleda said...

Tobias, thanks a lot, that is a good explanation, a few words more for beginners as me...

To connect as sysdba to allow this grant use a sentence like

CONNECT / as sysdba

in SQL plus


Rodrigo Rojas Moraleda

Tobias Arnhold said...

Hi Rodrigo,

thanks for your reply.

I try to explain more detailed next time.

Tobias

jf said...

Thanks for the help !! Why on earth was this not done (from Oracle) under the installation of Oracle XE 10g ?

Makes no sensence to have it but not see it ?!?

Cheers from Denmark

Jesper - DBA & Dev on Oracle v5-11

 

Google Translator

Visitor counter

Blogger statistics