Skip to Main Content

Analytics Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error while Sending alert Email using Python smtplib library in ODI

User_Z91K9Jun 1 2021

HI Team,
We have recently migrated our ODI 11g on-premise setup to a Oracle Cloud environment setup where we have ODI 12c and Autonomous Database for repository.
I have written ODI procedure with a Python code which uses smtp libraries to send alert email to users . This code was working fine on on-premise but on oracle cloud it is failing with below error:-
"File "/u01/oracle/mwh/odi/sdk/lib/Lib/_socket.py", line 1786, in getaddrinfo
raise gaierror(errno.ENOEXEC, 'nodename nor servname provided, or not known')
_socket.gaierror: [Errno 8] nodename nor servname provided, or not known"

Below is the code i am running :-
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import base64
import ssl

SENDER_EMAIL = 'xyz@abc.com'
RECEIVER_EMAIL_TO =['Gourav.Atalkar@abc.com']
PORT = '587'
SERVER = 'smtp.email.eu-frankfurt-1.oci.oraclecloud.com'
SUBJECT = 'ODI Load Monitoring Automated Update <@=load_date@>'
username ='OCI user name '
""
body
"""
message = MIMEMultipart("alternative", None, [MIMEText(HTML, 'html')])
message['Subject'] = SUBJECT
message['From'] = SENDER_EMAIL
message['To'] = ",".join(RECEIVER_EMAIL_TO)

#server = smtplib.SMTP(SERVER)
server = smtplib.SMTP(SERVER,PORT)
server.ehlo()

#server.starttls(context=ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH, cafile=None, capath=None))
server.ehlo()
# Step 8 - Switch the connection over to TLS encryption
server.starttls()
# Step 9 - Authenticate with the server
server.login(username, password)
server.sendmail(SENDER_EMAIL, RECEIVER_EMAIL_TO, message.as_string())
server.quit()

Comments
Post Details