You can
use the APEX_MAIL package to send email from Oracle APEX applications deployed in Autonomous Database.
Before you use APEX_MAIL you must configure an SMTP server that will
deliver email from Oracle APEX. Oracle APEX on Autonomous Database supports Oracle Cloud Infrastructure Email Delivery service as well as third party email providers.
Configure OCI Email Delivery Your Oracle APEX instance can utilize OCI Email Delivery service to send email from APEX applications.
Your
Oracle APEX instance can utilize OCI Email Delivery service to send email from APEX applications.
To configure APEX_MAIL functionality to use OCI Email Delivery service:
Identify the SMTP connection endpoint for Email Delivery. You configure the
endpoint as the SMTP Host in your APEX instance in Step 4. You may need to
subscribe to additional Oracle Cloud
Infrastructure regions if Email Delivery is not available in your current region. See Configure SMTP Connection
for more information.
Generate SMTP credentials for Email Delivery. Your APEX instance uses
credentials to authenticate with Email Delivery servers when you send email. See
Creating SMTP Credentials for more
information.
Create an approved sender for Email Delivery. You need to complete this step
for all email addresses you use as the "From" with
APEX_MAIL.SEND calls, as the Application Email "From"
address in your apps, or in the SMTP_FROM instance parameter.
See Managing Approved Senders
for more information.
Connect to your Autonomous Database
as ADMIN user using a SQL client and configure the following SMTP parameters
using APEX_INSTANCE_ADMIN.SET_PARAMETER:
SMTP_HOST_ADDRESS: Specifies the SMTP
connection endpoint from Step 1
SMTP_USERNAME: Specifies the SMTP
credential user name from Step 2
SMTP_PASSWORD: Specifies the SMTP
credential password from Step 2
SMTP_HOST_PORT: Keep the default value for
this parameter (587)
SMTP_TLS_MODE: Keep the default value for
this parameter (STARTTLS)
For example:
BEGIN
APEX_INSTANCE_ADMIN.SET_PARAMETER('SMTP_HOST_ADDRESS', 'smtp.email.us-phoenix-1.oci.oraclecloud.com');
APEX_INSTANCE_ADMIN.SET_PARAMETER('SMTP_USERNAME', 'ocid1.user.oc1.username');
APEX_INSTANCE_ADMIN.SET_PARAMETER('SMTP_PASSWORD', 'password');
COMMIT;
END;
/
Your Oracle APEX instance can utilize third party email providers to send email from APEX
applications.
Before configuring a third party email provider in APEX, ensure the following
prerequisites are met:
Your Autonomous Database must
be configured to use a Private Endpoint.
The email provider's SMTP endpoint (port 25 or 587) must be
accessible from the Virtual Cloud Network (VCN) and subnet where your Autonomous Database is provisioned.
If you set
ROUTE_OUTBOUND_CONNECTIONS database property to
PRIVATE_ENDPOINT, you do not need to define access
control lists for individual SMTP endpoints in order to access them from
APEX. See Enhanced Security for
Outbound Connections with Private Endpoints for more
information.
Connect to your Autonomous Database as ADMIN user using a SQL client and
configure the following SMTP parameters using
APEX_INSTANCE_ADMIN.SET_PARAMETER. If your third party
email provider does not require authentication, skip the
SMTP_USERNAME and SMTP_PASSWORD
parameters.
SMTP_HOST_ADDRESS: Specifies the SMTP
connection endpoint from Step 1
The valid values for SMTP_HOST_PORT
parameter are 25 or 587
Set the value for the SMTP_TLS_MODE
parameter to Y
Shows
the steps to confirm your email provider is ready to use with
APEX_MAIL.
Validate the email configuration settings using a SQL client as ADMIN:
BEGIN
APEX_INSTANCE_ADMIN.VALIDATE_EMAIL_CONFIG;
END;
/
If any errors are reported (for example, "ORA-29279:
SMTP permanent error: 535 Authentication credentials invalid"),
adjust the SMTP parameters or Virtual Cloud Network (VCN) configuration and
repeat the validation step.
Send a test email using APEX SQL Workshop, If you are using OCI Email Delivery, ensure the p_from parameter matches one of the approved
senders. For example:
BEGIN
APEX_MAIL.SEND(
p_from => 'alice@example.com',
p_to => 'bob@example.com',
p_subj => 'Email from Oracle Autonomous Database',
p_body => 'Sent using APEX_MAIL');
END;
/
Provides
notes for working with email providers in Oracle APEX from an Autonomous Database instance.
Note the following when working with email providers in Oracle APEX:
There is a default limit of 1,000 emails per workspace in a 24-hour
period. You can update or remove this limit in Oracle APEX Administration Services or by setting the
WORKSPACE_EMAIL_MAXIMUM instance parameter. If you are
using OCI Email Delivery service, the service may impose additional limitations.
When using OCI Email Delivery service, an approved sender must be set up for all possible βFromβ addresses
or mail will be rejected. See Managing Approved Senders
for more information.