Send emails with the OCI Email Service and Node.js

The Oracle Cloud Infrastructure (OCI) has an Email Service and like any other OCI service it can be accessed via the OCI CLI , REST API’s or one of the available SDK’s.

Oracle Cloud Infrastructure Email Delivery is an email sending service that provides a fast and reliable managed solution for sending high-volume emails that need to reach your recipients’ inbox. Email Delivery provides the tools necessary to send application-generated email for mission-critical communications such as receipts, fraud detection alerts, multi-factor identity verification, and password resets.

In the next steps I will configure this service and use Node.js to invoke it programmatically.

Create an Approved Sender

An approved sender must be set up for all “From:” addresses sending mail through Oracle Cloud Infrastructure, or mail is rejected.

Go To: Developer Services > Integration > Email Delivery > Approved Senders

You can define your own email and email domain, but that would take a bit longer and it’s not really necessary outside a Production environment. For pure testing we can use: noreply@notification.eu-frankfurt-1.oci.oraclecloud.com

Make note of the Public Endpoint as it will be required later on.

Create SMTP Credentials

Go to Identity/Users/User Details/SMTP Credentials

Save the password, as it wont be shown again.

Node.js Code

This code uses nodemailer.

npm install nodemailer is a prerequisite

And this is it