Survey banner
The Dataiku Community is moving to a new home! Some short term disruption starting next week: LEARN MORE

Create API endpoint for sending emails

Level 1
Create API endpoint for sending emails


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?

0 Kudos
1 Reply

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: 

Screen Shot 2023-01-31 at 1.30.39 PM.png

Here is the example Python function endpoint code where my SMTP server is running on

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'] = ''
    msg['To'] = ''

    # Send the message via our own SMTP server.
    s = smtplib.SMTP('')

    return {}


0 Kudos