ORACE APEX 18.2 之五(安裝mailgun-plsql-api)

ORACE APEX 18.2 之五(安裝mailgun-plsql-api)

  1. 创建mailgun_user
[oracle@XAG128 wallet]$ sql sys/[email protected]:1521/PDB1 as sysdba

SQL> SET SQLFORMAT ansiconsole
SQL> select tablespace_name,file_name,bytes/1024/1024 mb from dba_temp_files;
TABLESPACE_NAME  FILE_NAME                                       MB   
TEMP1            /u01/app/oracle/oradata/MPCDB/PDB1/TEMP1_1.dbf  256  
TEMP1            /u01/app/oracle/oradata/MPCDB/PDB1/TEMP1_2.dbf  256  
TEMP2            /u01/app/oracle/oradata/MPCDB/PDB1/TEMP2_1.dbf  256  


SQL> select tablespace_name,file_name,bytes/1024/1024 mb from dba_data_files;
TABLESPACE_NAME        FILE_NAME                                                                                             MB       
SYSTEM                 /u01/app/oracle/oradata/MPCDB/PDB1/system01.dbf                                                       380      
SYSAUX                 /u01/app/oracle/oradata/MPCDB/PDB1/sysaux01.dbf                                                       370      
UNDOTBS1               /u01/app/oracle/oradata/MPCDB/PDB1/undotbs01.dbf                                                      200      
PDB1_UD                /u01/app/oracle/oradata/MPCDB/PDB1/PDB1_UD1.dbf                                                       128      
PDB1_UD                /u01/app/oracle/oradata/MPCDB/PDB1/PDB1_UD2.dbf                                                       128      
I_PDB1_UD              /u01/app/oracle/oradata/MPCDB/PDB1/I_PDB1_UD1.dbf                                                     64       
I_PDB1_UD              /u01/app/oracle/oradata/MPCDB/PDB1/I_PDB1_UD2.dbf                                                     64       
APEX182                /u01/app/oracle/oradata/MPCDB/PDB1/apex182.dbf                                                        384      
APEX182_FILE           /u01/app/oracle/oradata/MPCDB/PDB1/apex182_file.dbf                                                   256      
ORDS183                /u01/app/oracle/oradata/MPCDB/PDB1/ords183.dbf                                                        256      
APEXTB                 /u01/app/oracle/oradata/MPCDB/PDB1/apextb.dbf                                                         128      


SQL> select * from dba_tablespace_groups;
GROUP_NAME  TABLESPACE_NAME  
TEMP_GP     TEMP1 

SQL> create user mailgun_user identified by "123456" default tablespace PDB1_UD temporary tablespace TEMP_GP;

SQL> grant dba to mailgun_user;
  1. 授權 mailgun_user 用戶 訪問 Logger架構下的對象
[oracle@xag182 logger]$ sql logger_user/[email protected]:1521/PDB1

SQL> SET SQLFORMAT ansiconsole

SQL> @/home/oracle/logger/scripts/grant_logger_to_user.sql mailgun_user 
old:grant execute on logger to &to_user
new:grant execute on logger to mailgun_user

Grant succeeded.

old:grant select, delete on logger_logs to &to_user
new:grant select, delete on logger_logs to mailgun_user

Grant succeeded.

old:grant select on logger_logs_apex_items to &to_user
new:grant select on logger_logs_apex_items to mailgun_user

Grant succeeded.

old:grant select, update on logger_prefs to &to_user
new:grant select, update on logger_prefs to mailgun_user

Grant succeeded.

old:grant select on logger_prefs_by_client_id to &to_user
new:grant select on logger_prefs_by_client_id to mailgun_user

Grant succeeded.

old:grant select on logger_logs_5_min to &to_user
new:grant select on logger_logs_5_min to mailgun_user

Grant succeeded.

old:grant select on logger_logs_60_min to &to_user
new:grant select on logger_logs_60_min to mailgun_user

Grant succeeded.

old:grant select on logger_logs_terse to &to_user
new:grant select on logger_logs_terse to mailgun_user

Grant succeeded.

  1. 在mailgun_user用戶下創建 Logger架構下的對象同義詞
[oracle@xag182 ~]$ sql mailgun_user/[email protected]:1521/PDB1

SQL> @/home/oracle/logger/scripts/create_logger_synonyms.sql logger_user
old:create or replace synonym logger for &from_user..logger
new:create or replace synonym logger for logger_user.logger

Synonym LOGGER created.

old:create or replace synonym logger_logs for &from_user..logger_logs
new:create or replace synonym logger_logs for logger_user.logger_logs

Synonym LOGGER_LOGS created.

old:create or replace synonym logger_logs_apex_items for &from_user..logger_logs_apex_items
new:create or replace synonym logger_logs_apex_items for logger_user.logger_logs_apex_items

Synonym LOGGER_LOGS_APEX_ITEMS created.

old:create or replace synonym logger_prefs for &from_user..logger_prefs
new:create or replace synonym logger_prefs for logger_user.logger_prefs

Synonym LOGGER_PREFS created.

old:create or replace synonym logger_prefs_by_client_id for &from_user..logger_prefs_by_client_id
new:create or replace synonym logger_prefs_by_client_id for logger_user.logger_prefs_by_client_id

Synonym LOGGER_PREFS_BY_CLIENT_ID created.

old:create or replace synonym logger_logs_5_min for &from_user..logger_logs_5_min
new:create or replace synonym logger_logs_5_min for logger_user.logger_logs_5_min

Synonym LOGGER_LOGS_5_MIN created.

old:create or replace synonym logger_logs_60_min for &from_user..logger_logs_60_min
new:create or replace synonym logger_logs_60_min for logger_user.logger_logs_60_min

Synonym LOGGER_LOGS_60_MIN created.

old:create or replace synonym logger_logs_terse for &from_user..logger_logs_terse
new:create or replace synonym logger_logs_terse for logger_user.logger_logs_terse

Synonym LOGGER_LOGS_TERSE created.
  1. 给mailgun_user用户授权
[oracle@xag182 mailgun]$ sql sys/[email protected]:1521/PDB1 as sysdba

SQL> @/home/oracle/mailgun/grants.sql
Enter the schema in which you will install mailgun: mailgun_user

old:grant create table to &&myschema
new:grant create table to mailgun_user

old:grant create job to &&myschema
new:grant create job to mailgun_user

old:grant create procedure to &&myschema
new:grant create procedure to mailgun_user

old:grant create type to &&myschema
new:grant create type to mailgun_user

old:grant execute on sys.dbms_aq to &&myschema
new:grant execute on sys.dbms_aq to mailgun_user

old:grant execute on sys.dbms_aqadm to &&myschema
new:grant execute on sys.dbms_aqadm to mailgun_user

old:grant execute on sys.dbms_job to &&myschema
new:grant execute on sys.dbms_job to mailgun_user

old:grant execute on sys.dbms_scheduler to &&myschema
new:grant execute on sys.dbms_scheduler to mailgun_user

old:grant execute on sys.utl_http to &&myschema
new:grant execute on sys.utl_http to mailgun_user
  1. Create Network ACL for https://api.mailgun.net
[oracle@xag182 mailgun]$ sql sys/[email protected]:1521/PDB1 as sysdba

SQL> 
   begin
        dbms_network_acl_admin.append_host_ace(
          host       => 'api.mailgun.net',
          lower_port => 443,
          upper_port => 443,
          ace        => xs$ace_type(
                          privilege_list => xs$name_list('connect'),
                          principal_name => 'mailgun_user', 
                          principal_type => xs_acl.ptype_db)
         ); 
     end;
     /

PL/SQL procedure successfully completed.
  1. Add the mailgun https certificate to your Oracle wallet
[oracle@xag182 wallet]$ ls
mailgun.cer

#Create a new wallet.
[oracle@XAG128 wallet]$ orapki wallet create -wallet /home/oracle/wallet -pwd Xag##123 -auto_login

#add the certificate
[oracle@XAG128 wallet]$ orapki wallet add -wallet /home/oracle/wallet -trusted_cert -cert /home/oracle/wallet/mailgun.cer -pwd Xag##123
  1. install
[oracle@XAG128 wallet]$ sql mailgun_user/[email protected]:1521/PDB1

SQL> @/home/oracle/mailgun/install.sql    
or  
@/home/oracle/mailgun/install_with_logger.sql  (logger授权后)

  1. Setup your mailgun parameters
SQL>
 begin
      mailgun_pkg.init
        (p_public_api_key  => 'pubkey-3d33dc779e30ead7fcf9c68150ed20ba'
        ,p_private_api_key => '168b5ce4b01c1e0a6cec42876e83e119-49a2671e-de8fc763'
        ,p_my_domain       => 'sandbox7adc16aadcca44d9b9630ab2c880ab72.mailgun.org');
    end;
    /

SQL> 
   begin
      mailgun_pkg.init
        (p_wallet_path     => 'file:/home/oracle/wallet'
        ,p_wallet_password => 'Xag##123');
    end;
    /


  1. test
SQL> 
  begin
      mailgun_pkg.send_email
        (p_from_email => 'mark.xu '
        ,p_to_email   => 'xuaiguo '
        ,p_subject    => 'test11'
        ,p_message    => 'Test Email Body'
        );
      commit;
      mailgun_pkg.push_queue;
   end;
   /

begin
  mailgun_pkg.send_email
    (p_from_email => 'xuaiguo '
    ,p_to_email   => 'mark.xu '
    ,p_subject    => 'test12'
    ,p_message    => 'Test Email Body'
    );
  commit;
  mailgun_pkg.push_queue;
end;

你可能感兴趣的:(ORACE APEX 18.2 之五(安裝mailgun-plsql-api))