Create API endpoint for sending emails
NiloofarDadras
Registered Posts: 1 ✭
Hi,
I am trying to set up dataiku API to send email to custom users with custom message once endpint gets triggered. because scenarios can not run in parallel i would not be able to use the following suggestion.
is there any other way to get it working in Dataiku?
Tagged:
Answers
-
Sarina Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 317 Dataiker
Hi @NiloofarDadras
,
If you want to send an email from an API endpoint, it's probably easiest to do this simply through a Python function in the API endpoint, and use Python to send the email. You can likely use the Python email package or any similar package.
Here is an example:Here is the example Python function endpoint code where my SMTP server is running on 0.0.0.0:1025:
import smtplib # Import the email modules we'll need from email.message import EmailMessage # Insert here initialization code # This function is the entry point for your Python function API # You can call this function with passing "param1", "param2", # "param3" as arguments to the API call # (see REST API documentation) def api_py_function(): print('do some stuff') print('sending email') msg = EmailMessage() msg.set_content('Your endpoint executed with the following results...') msg['Subject'] = 'Endpoint email' msg['From'] = 'sarina@dataiku.com' msg['To'] = 'sarina@dataiku.com' # Send the message via our own SMTP server. s = smtplib.SMTP('0.0.0.0:1025') s.send_message(msg) s.quit() return {}
Thanks,
Sarina