[OCI] How to Setup Self-Host SMTP Server on Oracle Cloud Infrastracture($0 cost)

Configuring an SMTP Server on Oracle Cloud Infrastructure can be a useful way to send email messages from your applications or services. However, Oracle Cloud Infrastructure will block Port 25 by default and it cannot be removed by configuring engress rule in the security list. To bypass it, you will need to create an Email Relay in the Oracle Cloud Infarstracture. In this blog, I will show you how to configure the SMTP relay on Oracle Cloud Infrastructure (OCI).

1. Email Delivery Configuraiton

First, log in to the Oracle Cloud Infrastructure Console and navigate to the Developer Services->Application Integration section. From there, click on the Email Delivery option in the left-hand menu.

Note that the Email Delivery feature is only accessible for paid account. It takes about 6 hours for OCI to process the upgrade request. (Paid account will still keep the Always Free tenancy)

On the Email Delivery page, click the Configuration option to retrieve the SMTP Sending Information.

Make a note of Public Endpoint, SMTP Ports, and that Transport Layer Security(TLS) is used on the connection, they will be used later. If you don’t have a SMTP Credential, click the Identity Interface link to navigate to your Identity pages and then click Generate SMTP Credentials to generate SMTP credentials for yourself or another user with permissions to manage email.

Enter a Description, such as Oracle Cloud SMTP Credential, and click Generate SMTP Credentials.

Copy the Username and Password for your record.

In order to properly set up your mail service, you’ll need to configure the Public Endpoint as the Relay Host, the SMTP Ports as the Relay Port, Username as the Relay User, and Password as the Replay Password. This will ensure that your mail service is able to send and receive messages properly. Keep in mind that these settings may vary depending on your specific mail service, so be sure to consult their documentation for more detailed instructions.

2. Email Domains

Next, select the Email Domain option, create a domain that you own. For example, example.com, then click Create Email Domain.

After creating your Email Domain, you have the option to add DKIM. DKIM is designed for security purpose. So I would suggest you to add one.

Note that you do not need to configure DKIM on your mail service as long as you have it set up on OCI.

Enter a DKIM Selector, such as examplesmtp-64-202212, and click Generate DKIM Record.

Copy the CNAME Record and CNAME Value for your record.

You will need to add the CNAME Record AND CNAME Value to your example.com DNS setting. Take AWS Route53 as an example:

3. Approved Senders

Last, select the Approved Senders option, add one of your existing email address as the email sender. For example, no-reply@example.com.

Once you have completed the configuration, you can start to test your email delivery funciton.

That’s it! You have successfully configured an SMTP relay on Oracle Cloud Infrastructure. With this SMTP relay, you can easily send email messages from your applications or services hosted in OCI Compartment.

If this post helped you to solve a problem or provided you with new insights, please upvote it and share your experience in the comments below. Your comments can help others who may be facing similar challenges. Thank you!
Buy Me A Coffee
Product Image

Learn More