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.
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.
Copy the code from Github and unzip or just clone the GitHub.
Go to the Github project folder
In Github, you should see something like:
For more details on the config file parameters and where to find the values, refer to the technical documentation.
Run the Python code.
It reads the "email_file.csv" and for all emails, it adds in the approved sender.
The second example "createsenderemail.py" adds one email and expects an email as a parameter. Replace "email@example.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