Sunday, August 30, 2020

Sending emails in Oracle Cloud using Email Delivery

 Few days back, i had a task to send emails from Oracle Cloud. My first pitstop was the Oracle Documentation oracle Notes which is very precise. 


1. The first step would be create a new non federated user. As a best practice, we should not use the user using which we do the console administration.


2. Create SMTP credentials for user



                                     






  Copy the password and keep it safe.


3.  Setup permissions and policy

The new user must be assigned to a group with permissions to manage approved-senders and suppressions


 





    4. Create an approved sender

     



     This user will be needed to send emails.

   








5.  Configure SPF on the approved sender domain






6. Configure the SMTP connection

 

Update the Postfix main.cf file.

 

To open the main.cf file, run the following command:

 

sudo vi /etc/postfix/main.cf

 

 

 

Add the following information to the end of the file:

 

smtp_tls_security_level = may

smtp_sasl_auth_enable = yes

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

smtp_sasl_security_options =

 

If the following line is present, either remove the line or turn it off:

smtpd_use_tls = yes

 

 

Update relayhost to include your SMTP connection endpoint and port.

relayhost = smtp.us-ashburn-1.oraclecloud.com:587

 

 

 

 

Create the sasl_passwd file in the same directory as main.cf

 

 

 

sudo vi /etc/postfix/sasl_passwd

 

 

add the content

smtp.us-ashburn-1.oraclecloud.com:587 ocid1.user.oc1..aaaaaaaacnikk6yarhsyxhjre7wdlzpt6jyj43i473m2uley4tup27snvyaa@***********..aaaaaaaaposae6cowatr3hfig5t46rhds6eapjn5a2rmovousqs76cyo43ta.ov.com:E1##48;8EnY}rSxA;(9J

 

 

Run the following command:

 

sudo chown root:root /etc/postfix/sasl_passwd

sudo chmod 600 /etc/postfix/sasl_passwd

 

 

Generate the password hash.

 

Run the following command:

 

sudo postmap hash:/etc/postfix/sasl_passwd

 

7. At this moment, we have completed the email delivery configuration. Now we need a relay server through which we can send the emails. Postfix is one of them and we are using it here.

1.      Start Postfix using root user

postfix start



8. Test email outbound


1.      Test email( using root user)

echo "This is a test message for postfix" | mail -s "Test Email-Delivery in OCI using Postfix from Samrat" -r samsin16@in.***com samratsinha05@gmail.com 


Ahh!!.. thats it. it wasn't complicated at all. The main objective is to get the right documentations and follow the steps one by one. 

Note: In Oracle EBS, we can also use this setup to configure our outbound mail server.


Hope, this helps someone


Issue:-

When Setting Up Email Delivery Service In OCI Error: "Email Is Not Available With Your Current Permissions. Contact Support in OCI instance" (Doc ID 2478986.1)

 

References:- https://docs.cloud.oracle.com/en-us/iaas/Content/Email/Reference/gettingstarted.htm

 

https://www.cyberciti.biz/faq/linux-unix-start-stop-restart-postfix/






No comments:

Post a Comment