<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to utilize databricks existing smtp or databricks api. in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/6884#M2886</link>
    <description>&lt;P&gt;@Krishna Prasad​&amp;nbsp;Depending on the emails and how you want them to be sent, you could check out &lt;A href="https://docs.databricks.com/sql/user/alerts/index.html" alt="https://docs.databricks.com/sql/user/alerts/index.html" target="_blank"&gt;Databricks Alerts&lt;/A&gt; where you can send alerts depending on custom logic with a Delta table. You could use Jobs to combine the notebooks and SQL alerts to raise alerts if a notebook failed or something.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Mar 2023 15:11:18 GMT</pubDate>
    <dc:creator>LandanG</dc:creator>
    <dc:date>2023-03-29T15:11:18Z</dc:date>
    <item>
      <title>Send custom emails from databricks notebook without using third party SMTP server. Would like to utilize databricks existing smtp or databricks api.</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/6883#M2885</link>
      <description>&lt;P&gt;We want to use existing databricks smtp server or if databricks api can used to send custom emails. Databricks Workflows sends email notifications on success, failure, etc. of jobs but cannot send custom emails. So we want to send custom emails to differentiate databricks environment whether email notifications are received from Dev, QA, Stage or Prod environment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What are other possible ways to send emails? Please advise.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used python smtplib package to send message but got error ConnectionRefusedError: [Errno 111] Connection refused at &lt;B&gt;smtpObj = smtplib.SMTP('localhost')&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;import smtplib&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;sender = 'abc@gcd.com'&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;receivers = ['myname@company.com']&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;message = """From: From Person &amp;lt;abc@gcd.com&amp;gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;To: To Person &amp;lt;myname@company.com&amp;gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;Subject: SMTP e-mail test&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;This is a test e-mail message.&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;"""&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;try:&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;smtpObj = smtplib.SMTP('localhost')&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;smtpObj.sendmail(sender, receivers, message)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;print ("Successfully sent email")&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;except SMTPException:&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;print ("Error: unable to send email")&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 09:53:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/6883#M2885</guid>
      <dc:creator>969091</dc:creator>
      <dc:date>2023-03-29T09:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to utilize databricks existing smtp or databricks api.</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/6884#M2886</link>
      <description>&lt;P&gt;@Krishna Prasad​&amp;nbsp;Depending on the emails and how you want them to be sent, you could check out &lt;A href="https://docs.databricks.com/sql/user/alerts/index.html" alt="https://docs.databricks.com/sql/user/alerts/index.html" target="_blank"&gt;Databricks Alerts&lt;/A&gt; where you can send alerts depending on custom logic with a Delta table. You could use Jobs to combine the notebooks and SQL alerts to raise alerts if a notebook failed or something.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 15:11:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/6884#M2886</guid>
      <dc:creator>LandanG</dc:creator>
      <dc:date>2023-03-29T15:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to utilize databricks existing smtp or databricks api.</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/6885#M2887</link>
      <description>&lt;P&gt;Hi @Krishna Prasad​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your question! To assist you better, please take a moment to review the answer and let me know if it best fits your needs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help us select the best solution by clicking on "Select As Best" if it does.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your feedback will help us ensure that we are providing the best possible service to you. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 03:51:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/6885#M2887</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-30T03:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/95643#M39134</link>
      <description>&lt;P&gt;Currently, the Alert service only allow to send a fix email list. can we send dynamic based on the a column in the dataset ? e.g. i have a dataset which includes a email column, can i send email to each row based on columns ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 06:14:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/95643#M39134</guid>
      <dc:creator>htv</dc:creator>
      <dc:date>2024-10-23T06:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/111029#M43766</link>
      <description>&lt;P&gt;Hello. Did you figure this out? We have a similar problem and this approach could potentially be a nice solution.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2025 10:50:15 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/111029#M43766</guid>
      <dc:creator>pavlos_skev</dc:creator>
      <dc:date>2025-02-24T10:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/111393#M43873</link>
      <description>&lt;P&gt;So you could do this via the api and combine with alerts. The challenge is obtaining the query_ids needed to create the notification and the notification destinations themselves -&amp;nbsp; it would go something like this -&lt;BR /&gt;&lt;BR /&gt;- Save your queries as actual "queries" in Databricks&lt;BR /&gt;&amp;nbsp;- Create a table storing your metadata, so the query display name, email recipients, a column for the trigger column and a column for the query_id&lt;/P&gt;
&lt;P&gt;- Use the &lt;A href="https://databricks-sdk-py.readthedocs.io/en/latest/workspace/settings/notification_destinations.html" target="_self"&gt;notification_destination&lt;/A&gt; api, iterate through your table and create a destination per email in your table&lt;BR /&gt;- Use the &lt;A href="https://databricks-sdk-py.readthedocs.io/en/latest/workspace/sql/queries.html#databricks.sdk.service.sql.QueriesAPI" target="_self"&gt;queries&lt;/A&gt; api, iterate through the queries you own using&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;queries.&lt;/SPAN&gt;&lt;SPAN&gt;list&lt;/SPAN&gt;&lt;SPAN&gt;() - update your metadata table query_id by joining on display_name and updating the query_id. Note, you can combine this step with the next by doing the queries_create() api at the same time if your queries themselves are stored in a table. This is quite intensive so it might be better to create the queries via the api and retrieve the query_id at the same time&lt;BR /&gt;- Now you've got your query_ids and notification defined, you can then iterate through your table to create your actual alerts, passing through your destinations and queries that you've now defined, there's an example &lt;A href="https://github.com/databricks/databricks-sdk-py/blob/main/examples/workspace/alerts/create_alerts.py" target="_self"&gt;here&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Might sound a bit clunky - if you're happy to wait i'm building a POC for a customer as we speak doing this very thing, if you're happy to wait a few days i'll share the final code here &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 17:06:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/111393#M43873</guid>
      <dc:creator>mido1978</dc:creator>
      <dc:date>2025-02-27T17:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/113025#M44395</link>
      <description>&lt;P&gt;Hey - i ended up writing a blog on this, hopefully a simpler way of doing things than I thought &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://sqlofthenorth.blog/2025/03/04/data-driven-notifications-with-databricks/" target="_blank"&gt;https://sqlofthenorth.blog/2025/03/04/data-driven-notifications-with-databricks/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 09:15:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/113025#M44395</guid>
      <dc:creator>mido1978</dc:creator>
      <dc:date>2025-03-19T09:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/113026#M44396</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/63095"&gt;@mido1978&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am also in need&amp;nbsp;of something similar.&lt;/P&gt;&lt;P&gt;I have two tables one has the details of the recipient and another has some log data which are identified by a common key. Emails need be sent with the mentioned log to the recipient for whom it's applicable.&lt;/P&gt;&lt;P&gt;Please share the POC/code when it's ready&lt;SPAN&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 09:17:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/113026#M44396</guid>
      <dc:creator>pk13</dc:creator>
      <dc:date>2025-03-19T09:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/113029#M44398</link>
      <description>&lt;P&gt;hey&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/154185"&gt;@pk13&lt;/a&gt;&amp;nbsp;see my reply this morning, hope this is of use for you?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 10:07:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/113029#M44398</guid>
      <dc:creator>mido1978</dc:creator>
      <dc:date>2025-03-19T10:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/122708#M46846</link>
      <description>&lt;P&gt;I saw your code from the link you provided.&amp;nbsp; But it is using the third party smtp server.&amp;nbsp; Is there any function that directly from the Databrick it was hosted? I can use the notification of job to send standard success fail email.&amp;nbsp; How that function to send the email?&amp;nbsp; Thank you so much!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 15:45:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/122708#M46846</guid>
      <dc:creator>JohnnyWong120</dc:creator>
      <dc:date>2025-06-24T15:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/127824#M48093</link>
      <description>&lt;P&gt;Any update on the original request of not using 3rd party smtp server for custom emails? Can that be done outside of Alerts or the default Job Notifications?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Aug 2025 14:59:13 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/127824#M48093</guid>
      <dc:creator>JR-20773</dc:creator>
      <dc:date>2025-08-08T14:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Send custom emails from databricks notebook without using third party SMTP server. Would like to</title>
      <link>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/142189#M51897</link>
      <description>&lt;P&gt;Did you able to get the custom email working from databricks notebook. I was trying but was not successful. let me know&lt;/P&gt;</description>
      <pubDate>Thu, 18 Dec 2025 17:14:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/send-custom-emails-from-databricks-notebook-without-using-third/m-p/142189#M51897</guid>
      <dc:creator>Shivaprasad</dc:creator>
      <dc:date>2025-12-18T17:14:05Z</dc:date>
    </item>
  </channel>
</rss>

