Checking the correctness of the e-mail address. whether it is valid

You are super. @iCFO :wink: I hope you can achieve a successful result.

No good news @umutcankurt… While it seems relatively easy to check the email address structure via regex and reliably validate domains, validating individual email addresses within a domain is proving to be quite a challenge. I have tried dozens of different approaches with ChatGPT and all have failed and the same code approaches just get recommended in a cycle. I have had several code iterations that ChatGPT insists are successfully testing the individual email address validity, however it said that most domains block these validity tests so it returns the same results for the entire domain. I even went so far as to send test emails for the validity check. Even with that approach it still couldn’t detect failure other than receiving the standard “Undeliverable:” email in the inbox.

Ultimately ChatGPT continually came back around to recommending a paid API service for validating email addresses, which it caveats by saying that they tend to generate inconsistent results and were more consistent at validating domains. Several had free tiers that handled up to 100 validations.

I will dig back into this every once and a while and see if I can spot anything promising. For now I think that I will take the approach of reading back in the “Undeliverable:” system messages from the sending inbox that occur around bulk report email distributions, then compile a list of the failed email addresses and then have the system email them to the appropriate admin for updating. That doesn’t get ahead of the underlying problem, but it at least provides a way to track and manage emails that require re-sending to new addresses / initiates the correction of distribution list issues.

1 Like

Here was one of the better python codes if anyone wants to explore a bit. This was my first ever Python interaction, so I am by no means the final word! I pulled out the regex test to isolate during testing, and since that is easy to do with standard nodes within KNIME already. I recommend just creating a temporary email addresses for testing stuff like this you don’t have to sweat security. (this one was “” based) Anything reading in BOLD is a comment that has a # in front of it in they python code.

import as knio

This example script simply outputs the node’s input table.

knio.output_tables[0] = knio.input_tables[0]

import re
import smtplib
import dns.resolver

SMTP server settings

smtp_server = ‘
smtp_port = 587
smtp_encryption = ‘STARTTLS’
username = ‘EnterYourUserNameHere’
password = ‘EnterYourPasswordHere’

Address used for SMTP MAIL FROM command

fromAddress = ‘EnterSendingEmailAddressHere’

Email address to verify

inputAddress = ‘’
addressToVerify = str(inputAddress)

Get domain for DNS lookup

splitAddress = addressToVerify.split(‘@’)
domain = str(splitAddress[1])
print(‘Domain:’, domain)

MX record lookup

records = dns.resolver.resolve(domain, ‘MX’)
mxRecord = records[0].exchange
mxRecord = str(mxRecord)
except dns.resolver.NoAnswer:
print(f"No MX records found for {domain}“)
except dns.resolver.NXDOMAIN:
print(f"Domain {domain} does not exist”)

SMTP lib setup (use debug level for full output)

server = smtplib.SMTP(smtp_server, smtp_port)

SMTP Conversation

server.ehlo() # Identify yourself to the server
server.starttls() # Start a secure connection
server.ehlo() # Re-identify yourself to the server after starting TLS
server.login(‘EnterYourUserNameHere’, ‘EnterYourPasswordHere’) # Login with email credentials
code, message = server.rcpt(str(addressToVerify))


#Assume SMTP response 250 is success
if code == 250:
print((inputAddress)+’ - address exists’)
print((inputAddress)+’ - address does not exist’)


@iCFO Really thank you so much. It was a very informative and detailed description of the experience.

I couldn’t be as detailed as you. Therefore, I appreciate it, I will look into this issue from time to time, if there is a valid solution, I will share it. Maybe someone who finds a valid solution will add it as a comment to this post.

Thanks again for all your work.

1 Like

This turned out to be an amazing project on my end as well. It motivated me to take the leap into Python environments / code and learn to incorporate Chat GPT into my workflow / learn to prompt it more effectively. One better phrased detailed question to GPT-4 got me straight to the answer that this was not really possible at this point. Chat GPT has instantly become part of my workflow and is opening up new opportunities for my company. I am now incorporating it into KNIME to see what it can do with data sets as well. Thanks for the motivation!