M.kashif raja
M.kashif raja

Reputation: 1

Why the SMTP Connection unexpectedly closes while trying outlook and yahoo server?

I'm validating the email with smtp server connection using rcpt command. It is working fine with google but when I try with outlook and yahoo email it shows "SMTP connection error: Connection unexpectedly closed "

my code is here

def check_smtp(self, email):
    host = socket.gethostname()
    server = smtplib.SMTP(port=self.smtp_port_number, timeout=self.connection_timeout)
    server.set_debuglevel(100)
    server.connect(self.get_MX_records(email.split('@')[1]))
    server.helo(host)
    server.mail('[email protected]')
    code, message = server.rcpt(str(email))
    server.quit()
    if code == 250:
        return True
    else:
        return False

Here is my input {"email": "[email protected]"}

Upvotes: 0

Views: 102

Answers (1)

Mitul Kalsariya
Mitul Kalsariya

Reputation: 1

It's likely because your IP is blacklisted or the SMTP handshake is not being established properly.

You can try using your home network; it might work.

Since I have developed an email verification API tool, I occasionally encounter these kinds of issues as well.

Upvotes: 0

Related Questions