Skip to content

Setting Up Email Configuration on OCI VM Instance: A Step-by-Step Guide

How to make emails work on OCI VM instance. (works with Magento and Cloudpanel )

Setting Up Email Configuration on OCI VM Instance: A Step-by-Step Guide

Introduction: Configuring email services on an OCI (Oracle Cloud Infrastructure) VM instance can be a challenging task, especially for those who are not advanced developers. In this guide, we will walk you through the process of setting up emails on an OCI VM instance using Postfix and Mailutils. By following these step-by-step instructions, you'll be able to successfully configure your email services and ensure reliable communication.

Step 1: Update Packages and Install Postfix and Mailutils

Log in to your OCI VM instance as root:

sudo su -

Navigate to the root directory:

cd /

Update the package lists to ensure you have the latest versions:

sudo apt update

Install Postfix and Mailutils:

sudo apt install postfix mailutils

Step 2: Configuring Postfix for Outgoing Mail

During the installation process, you will be prompted to choose a General type configuration. Select "Internet with smart host" instead of "Internet Site."

Next, you'll need to enter the "System mail name." This should be the domain name associated with your server or the hostname of your machine. It is recommended to use a domain name you have control over.

You'll then be asked to enter the "SMTP relay host" for outgoing mail. Here, you need to specify the SMTP server provided by your mail provider, such as Namecheap. Consult your provider's documentation or contact their support to obtain the SMTP server address (e.g., "" or "").

Step 3: Editing the Postfix Configuration

Open the main configuration file for Postfix:
sudo nano /etc/postfix/
Locate the following lines in the file and make the necessary changes:
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname =        # Replace with your own domain name or host FQDN
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = [email protected]        # Replace with a valid working email address ur own domain
mydestination =, $myhostname, cloud, localhost.localdomain, localhost
relayhost =       # Replace with your SMTP host
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
# add below line as it is
sender_canonical_maps = hash:/etc/postfix/sender_canonical regexp:/etc/postfix/sender_canonical
inet_interfaces = all
inet_protocols = all

Save the changes and exit the text editor.

Step 4: Configuring Sender Canonical Mapping

Open the sender canonical mapping file:

sudo nano /etc/postfix/sender_canonical

Add the following line to the mapping file, replacing [email protected] with a valid working email address:

/^.*$/    [email protected]

Save the changes and exit the text editor.

Generate the sender canonical database:

sudo postmap /etc/postfix/sender_canonical

Step 5: Setting Up Email Aliases

Open the aliases file:

sudo nano /etc/aliases

Locate the line that starts with root: and modify it to assign a valid email address for the root user. For example:

Save the changes and exit the text editor.

Apply the changes to the aliases database:

sudo newaliases

Step 6: Restart Postfix To ensure that all the changes take effect, restart the Postfix service:

sudo service postfix restart

Step 7: Testing the Email Configuration To verify that your email setup is working correctly, you can send a test email. Use the following command:

echo "This is the email body" | mail -s "Test Subject" [email protected]
Note: Replace [email protected] with a valid email address within your domain.

Conclusion: By following the steps outlined in this guide, you can successfully configure email services on your OCI VM instance using Postfix and Mailutils. Remember to adapt the instructions to your specific DNS provider and SMTP server. With a functional email setup, you can ensure reliable communication and streamline your business or personal email needs on your OCI infrastructure.

Disclaimer: The instructions provided in this blog post are based on personal experience and may vary depending on your specific setup and requirements. It's always recommended to consult official documentation and seek support from your DNS and SMTP service providers if needed.
Sign In or Register to comment.