title: Send email from Databricks Notebook with attachment
body: <p>I'm a newbie in Python and Spark world. And am trying to build a pyspark code to send an email from Databricks along with the attachment from the mount point location. I'm using below code to implement the same -</p>
  <pre><code>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 = &lt;from_email&gt;, send_to = &lt;to_email&gt;, subject = &quot;Test&quot;, message = &quot;Test&quot;, files=[&quot;/mnt/&lt;Mounted Point Directory&gt;/&quot;],
                server=&quot;&lt;SMTP Host&gt;&quot;, port=&lt;SMTP Port&gt;, username='&lt;SMTP Username&gt;', password='&lt;SMTP Password&gt;',
                use_tls=True):
  
      msg = MIMEMultipart()
      msg['From'] = send_from
      msg['To'] = COMMASPACE.join(send_to)
      msg['Date'] = formatdate(localtime=True)
      msg['Subject'] = subject
  
      msg.attach(MIMEText(message))
  
      for path in files:
          part = MIMEBase('application', &quot;octet-stream&quot;)
          with open(path, 'rb') as file:
              part.set_payload(file.read())
          encoders.encode_base64(part)
          part.add_header('Content-Disposition',
                          'attachment; filename=&quot;{}&quot;'.format(Path(path).name))
          msg.attach(part)
  
      smtp = smtplib.SMTP(server, port)
      if use_tls:
          smtp.starttls()
      smtp.login(username, password)
      smtp.sendmail(send_from, send_to, msg.as_string())
      smtp.quit()
  
  </code></pre>
  <p>But for some reason the code is giving me File or directory not exists exception.</p>
  <p>Am I missing anything over here.</p>
  <p>Thanks</p>