Showing results for 
Search instead for 
Did you mean: 
Administration & Architecture
Explore discussions on Databricks administration, deployment strategies, and architectural best practices. Connect with administrators and architects to optimize your Databricks environment for performance, scalability, and security.
Showing results for 
Search instead for 
Did you mean: 

Send formatted html email from email distribution address

New Contributor

Hi, I have created an email distribution list "". In the RShiny world I was able to send emails by a) getting the IP of the server I was sending the emails from and b) whitelisting that IP address within my company's SMTP Relay registry. At that point I could send my email using a function like this:

      mailR::send.mail(from = '', to = sendto,
                       subject = subject, body = email_fname,
                       attach.files = attach.files, html = T, inline = T,
                       smtp = list(, port = smtPort),
                       authenticate = F, send = T)

What do I need to do to set up a similar service in databricks?


Community Manager
Community Manager

Hi @mchirouzeTo set up email services in Databricks, you have a few options depending on your requirements. Let’s explore them:

  1. Workspace Email Settings:

  2. Job Notifications:

    • If you want to receive email notifications specifically for job events (such as job runs beginning, completing, or failing), follow these steps:
  3. Sending Custom Emails from a Databricks Notebook:

    • If you need to send custom emails from a Databricks notebook, you can use Python code.
    • Here’s an example of how to send an email with an attachment from a Databricks notebook using Python:
      import smtplib
      from pathlib import Path
      from email.mime.multipart import MIMEMultipart
      from email.mime.base import MIMEBase
      from email.mime.text import MIMEText
      from email.utils import COMMASPACE, formatdate
      from email import encoders
      def send_mail(send_from, send_to, subject, message, files, server, port, username, password, use_tls=True):
          msg = MIMEMultipart()
          msg['From'] = send_from
          msg['To'] = COMMASPACE.join(send_to)
          msg['Date'] = formatdate(localtime=True)
          msg['Subject'] = subject
          for path in files:
              part = MIMEBase('application', "octet-stream")
              with open(path, 'rb') as file:
              part.add_header('Content-Disposition', f'attachment; filename="{Path(path).name}"')
          smtp = smtplib.SMTP(server, port)
          if use_tls:
          smtp.login(username, password)
          smtp.sendmail(send_from, send_to, msg.as_string())
      # Example usage:
                send_to=["", ""],
                subject="Test Email",
                message="This is a test email from Databricks.",
                files=["/dbfs/mnt/<Mount Point Directory>/file.txt"],
                server="<SMTP Host>",
                port=<SMTP Port>,
                username="<SMTP Username>",
                password="<SMTP Password>")
    • Make sure to adjust the placeholders (<...>) with your actual values, including the file path on DBF...3.
  4. Amazon SES Integration:

Choose the option that best fits your use case, and you’ll be able to set up email services within Databricks. 📧

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!