-
Notifications
You must be signed in to change notification settings - Fork 9
Installation
- Oracle Database 11gR2 or later
- Oracle Application Express 5.0 or later (just for the apex packages)
(some modification of the code may be required to run this on earlier versions, but it should be feasible)
You can install the API in any schema that has the following grants:
grant create job to myschema;
grant create procedure to myschema;
grant execute on apex_debug to myschema;
grant execute on apex_json to myschema;
grant execute on apex_util to myschema;
grant execute on dbms_aq to myschema;
grant execute on dbms_aqadm to myschema;
grant execute on dbms_output to myschema;
grant execute on dbms_scheduler to myschema;
grant execute on dbms_utility to myschema;
grant execute on utl_http to myschema;
Your Oracle database server needs to be able to connect to the Mailgun API via Secure HTTP. There are two methods I can suggest to do this:
- Oracle wallet
- Reverse proxy
- Create Network ACL for
https://api.mailgun.net(see example below) - Add the mailgun https certificate to your Oracle wallet (for more help, refer: https://oracle-base.com/articles/misc/utl_http-and-ssl)
NETWORK ACL example (method 1)
begin
dbms_network_acl_admin.create_acl (
acl => 'mailgun.xml',
description => 'Mailgun API',
principal => 'yourschema', -- put your schema here
is_grant => true,
privilege => 'connect');
dbms_network_acl_admin.assign_acl (
acl => 'mailgun.xml',
host => 'api.mailgun.net',
lower_port => 443);
commit;
end;
/
- Set up a reverse proxy on your server to
https://api.mailgun.net(see apache example below) - Create Network ACL for
http://api.mydomain.com(see example below)
Note: I've used api.mydomain.com in this example, but you could choose anything as long as you've set up the DNS to point to your server.
Reverse proxy example for Apache
<VirtualHost *:80>
ServerName api.mydomain.com
SSLProxyEngine on
ProxyPass /mailgun https://api.mailgun.net
ProxyPassReverse /mailgun https://api.mailgun.net
ProxyRequests Off
</VirtualHost>
NETWORK ACL example (method 2)
begin
dbms_network_acl_admin.create_acl (
acl => 'mailgun.xml',
description => 'Mailgun API',
principal => 'yourschema', -- put your schema here
is_grant => true,
privilege => 'connect');
dbms_network_acl_admin.assign_acl (
acl => 'mailgun.xml',
host => 'api.mydomain.com',
lower_port => 80);
commit;
end;
/
Download the latest release.
If your schema has an older version of the mailgun API installed, uninstall it using:
@uninstall.sql
Edit the following constants in mailgun_pkg.pkb:
-
p_public_api_key- required for validating email addresses -
p_private_api_key- required for sending emails -
p_my_domain- required for sending emails -
p_api_url- if you are using a reverse proxy, you will need to change this from the defaul -
p_wallet_path- required if default https endpoint is used -
p_wallet_password- required if default https endpoint is used
Run the following script to create the mailgun objects in your schema, the queue and scheduler job:
@install.sql
You may adapt and use the supplied test script if you wish.