<?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 email from notebook getting &amp;quot;SMTPHeloError: (501, b'5.5.4 Invalid domain name.....&amp;quo in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4277810#M5115</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Thanks for the reply,&amp;nbsp;the&amp;nbsp;SMTP sever info I used is as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{
    "SMTP": {
        "sever": "smtp.office365.com",
        "port": 587,
        "encrypt": "TLS"
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;As you said,&amp;nbsp; is there another different&amp;nbsp;&lt;SPAN&gt;SMTP sever available in notebook?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Nov 2024 07:54:32 GMT</pubDate>
    <dc:creator>ZJoe</dc:creator>
    <dc:date>2024-11-11T07:54:32Z</dc:date>
    <item>
      <title>Send email from notebook getting "SMTPHeloError: (501, b'5.5.4 Invalid domain name....."</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4277330#M5104</link>
      <description>&lt;P&gt;Hi, I'm trying to send email with a python notebook, using smtplib.&lt;/P&gt;&lt;P&gt;all&amp;nbsp;the code works fine on my desktop using a py script, but when I migrate it to the notebook, it failed with error below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SMTPHeloError: (501, b'5.5.4 Invalid domain name [BY5PR17CA0023.namprd17.prod.outlook.com 2024-11-11T00:38:48.583Z 08DD01A7D38EEEA9]')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the debug info with "&lt;SPAN&gt;set_debuglevel(&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;send: 'ehlo vm-db444797.\r\n'
reply: b'501 5.5.4 Invalid domain name [BY5PR17CA0023.namprd17.prod.outlook.com 2024-11-11T00:38:43.583Z 08DD01A7D38EEEA9]\r\n'
reply: retcode (501); Msg: b'5.5.4 Invalid domain name [BY5PR17CA0023.namprd17.prod.outlook.com 2024-11-11T00:38:43.583Z 08DD01A7D38EEEA9]'
send: 'helo vm-db444797.\r\n'
reply: b'501 5.5.4 Invalid domain name [BY5PR17CA0023.namprd17.prod.outlook.com 2024-11-11T00:38:48.583Z 08DD01A7D38EEEA9]\r\n'
reply: retcode (501); Msg: b'5.5.4 Invalid domain name [BY5PR17CA0023.namprd17.prod.outlook.com 2024-11-11T00:38:48.583Z 08DD01A7D38EEEA9]'
send: 'QUIT\r\n'
reply: b'221 2.0.0 Service closing transmission channel\r\n'
reply: retcode (221); Msg: b'2.0.0 Service closing transmission channel'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&amp;nbsp;the code snippet I used is as follows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with smtplib.SMTP(self.__smtp_host, self.__smtp_port) as s:
    if debug:
        s.set_debuglevel(1)
    s.starttls()
    s.login(self._from, self.__pwd) 
    s.send_message(self.msg)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this a notebook related issue? and how should we fix it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2024 01:47:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4277330#M5104</guid>
      <dc:creator>ZJoe</dc:creator>
      <dc:date>2024-11-11T01:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from notebook getting "SMTPHeloError: (501, b'5.5.4 Invalid domain name.....&amp;quo</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4277776#M5113</link>
      <description>&lt;P&gt;Hi, what SMTP server are you using to set up your SMTP client? It seems like the server you provided may be only available on your local device and not in the Python Notebook.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2024 07:32:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4277776#M5113</guid>
      <dc:creator>FabianSchut</dc:creator>
      <dc:date>2024-11-11T07:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from notebook getting "SMTPHeloError: (501, b'5.5.4 Invalid domain name.....&amp;quo</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4277810#M5115</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks for the reply,&amp;nbsp;the&amp;nbsp;SMTP sever info I used is as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{
    "SMTP": {
        "sever": "smtp.office365.com",
        "port": 587,
        "encrypt": "TLS"
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;As you said,&amp;nbsp; is there another different&amp;nbsp;&lt;SPAN&gt;SMTP sever available in notebook?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2024 07:54:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4277810#M5115</guid>
      <dc:creator>ZJoe</dc:creator>
      <dc:date>2024-11-11T07:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from notebook getting "SMTPHeloError: (501, b'5.5.4 Invalid domain name.....&amp;quo</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4278053#M5119</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/843780"&gt;@ZJoe&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the codes from this blog (&lt;A href="https://medium.com/@vipulbajaj/how-to-send-emails-using-python-and-office365-smtp-server-f5f2dab3432" target="_blank" rel="noopener"&gt;How to send emails using Python and Office365 SMTP server | by Vipul Bajaj | Medium&lt;/A&gt;) in a Fabric notebook and got the same&amp;nbsp;&lt;SPAN&gt;"SMTPHeloError: (501, b'5.5.4 Invalid domain name....." error in Fabric portal.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, when I ran the same Fabric notebook in the VS Code with Synapse VS Code extension, and used Fabric runtime 1.2, I sent the email successfully! You may give this a try.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vjingzhanmsft_0-1731318044670.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1197564iB43E04C5E271D53C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vjingzhanmsft_0-1731318044670.png" alt="vjingzhanmsft_0-1731318044670.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems when running the notebook in Fabric portal, it automatically generates an invalid domain name which has some timestamp and other information at the end. However a valid domain name should probably ends with ".com". Maybe we can consider update the domain name in the notebook to provide a valid one, but I haven't figure out whether this is possible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;SMTPHeloError: (501, b'5.5.4 Invalid domain name [BY5PR17CA0023.namprd17.prod.outlook.com&lt;FONT color="#FF0000"&gt; 2024-11-11T00:38:48.583Z 08DD01A7D38EEEA9&lt;/FONT&gt;]')&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Jing&lt;BR /&gt;If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2024 09:47:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4278053#M5119</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-11T09:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from notebook getting "SMTPHeloError: (501, b'5.5.4 Invalid domain name.....&amp;quo</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4278849#M5126</link>
      <description>&lt;P&gt;Thanks for your try! but finally I need to add this notebook to a pipeline and make it running automatically, so using the VS Code may not help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And as you said,&amp;nbsp;&lt;SPAN&gt;an invalid domain name may be&amp;nbsp;generated in a Fabric portal, and I had found a same issue in&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/44763856/office365-smtp-server-does-not-respond-to-ehlo-in-python" target="_self"&gt;stackoverflow&amp;nbsp;&lt;/A&gt;(but it's not in a Fabric notebook) .&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried to add the codes it mentioned, and it works, by&amp;nbsp;explicitly setting sender host name in the ehlo command&amp;nbsp;to anything lowercase.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import smtplib
server_365 = smtplib.SMTP('smtp.office365.com', '587')
server_365.ehlo('mylowercasehost')
server_365.starttls()
server_365.ehlo('mylowercasehost')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;what's more, I found another way to write the code in&amp;nbsp;&lt;A href="https://docs.python.org/3/library/smtplib.html#smtplib.SMTP" target="_self"&gt;the docs of smtplib&lt;/A&gt;, it also works, as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import smtplib
server_365 = smtplib.SMTP('smtp.office365.com', '587', local_hostname='mylowercasehost')
server_365.starttls()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 01:27:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4278849#M5126</guid>
      <dc:creator>ZJoe</dc:creator>
      <dc:date>2024-11-12T01:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from notebook getting "SMTPHeloError: (501, b'5.5.4 Invalid domain name.....&amp;quo</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4279179#M5131</link>
      <description>&lt;P&gt;Great! Thank you for sharing the solution. Please accept your reply as solution, this will help other people find the solution quickly!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Jing&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 05:43:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4279179#M5131</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-12T05:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from notebook getting "SMTPHeloError: (501, b'5.5.4 Invalid domain name.....&amp;quo</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4654591#M8629</link>
      <description>&lt;P&gt;Great Job!!! Thank you for sharing the solution.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Hugo&lt;/P&gt;</description>
      <pubDate>Tue, 15 Apr 2025 20:10:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Send-email-from-notebook-getting-quot-SMTPHeloError-501-b-5-5-4/m-p/4654591#M8629</guid>
      <dc:creator>Pfeifer</dc:creator>
      <dc:date>2025-04-15T20:10:07Z</dc:date>
    </item>
  </channel>
</rss>

