X

Break New Ground

Easily configure many approved senders

Igor Aragao de Souza
Principal Big Data Consultant

A while back, we launched the Email Delivery for Oracle Cloud Infrastructure, and the service got much more interesting since, for example, last week a few enhancements were just announced.

Email Delivery provides a highly scalable, cost-effective, and reliable way to send email from your applications. Email Delivery includes developer-friendly tools to quickly send an application-generated email for mission-critical communications such as receipts, programmatic notifications, or password reset emails.

If you are not familiar with OCI Email Delivery you can check the Overview of the Email Delivery Service.

When getting started with Email Delivery, one of the first things you will need to do is create an approved sender. Setting up approved senders is required so that your emails are successfully relayed by Oracle Cloud Infrastructure's Email Delivery Service. Each 'from address' must be defined as an 'approved sender' in our service so that we can protect your sending domains from abuse like spoofing.

The approved sender resource is associated with a compartment and only exists in the region where the approved sender was configured. If you want to use the same approved sender in another region, it must be created in the other region. For example, if you create an approved sender in the US West (Phoenix) region, you cannot send email through the US East (Ashburn) region without creating the same approved sender in US East (Ashburn).

 If you have only a few addresses that your mail is sent from, configuring your approved senders can easily be done manually one by one. 

But what if you have a big list of emails to add? What if you send from 10s, 100s, or even 1,000s of email addresses. Adding each address one by one is not a good use of time. Could I easily add it all?

Oracle provides a REST interface that you can use to add, but we are just publishing a Python code that does this for you.

Today, we’re excited to publish a reference solution that will help you to easily configure many approved senders at the same time using a Python script. 

Solution

You can get the full code on my GitHub for these two solutions for adding approved senders to an OCI Email Delivery Service tenancy. Both solutions share the same "config" file shown below.

  1. Add multiple approved senders from a file by using the createsender.py. The program reads a "file.txt" or "file.csv" containing a list of email addresses. For each email address in the file, an approved sender address is configured in OCI tenancy's region and compartment.  
  2. Add a single approved sender by using createsenderwithemail.py and defining the approved sender address to be configured in the OCI tenancy's region and compartment.

Step-by-step guide

  1. Copy the code from Github and unzip or just clone the GitHub.

  2. Go to the Github project folder

    In Github, you should see something like:




     
  3. Update the de "config" with your specific details as shown below

    For more details on the config file parameters and where to find the values, refer to the technical documentation.

  4. Update or create the "email_file.csv" with the emails that you want to be added as an approved sender
  5. Run the Python code.
     

    It reads the "email_file.csv" and for all emails, it adds in the approved sender. 

     

  6. The second example "createsenderemail.py" adds one email and expects an email as a parameter. Replace "user1@test.com" with the email that you want to add.

Both solutions create a log.txt file with all details and it prints all e-mails that for some reason failed to be added.

 

Photo by Markus Winkler on Unsplash

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.