Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom handle_HELO and handle_EHLO: 503 Error: send HELO first #406

Closed
tobwen opened this issue Feb 11, 2024 · 1 comment
Closed

custom handle_HELO and handle_EHLO: 503 Error: send HELO first #406

tobwen opened this issue Feb 11, 2024 · 1 comment

Comments

@tobwen
Copy link

tobwen commented Feb 11, 2024

summary

I've changed handle_HELO and handle_EHLO to get rid of unwanted hostnames as early as possible. Disappointingly, I am now stuck with the message 503 Error: send HELO first.

expected

220 v238348.srv.net Python SMTP 1.4.4.post2
HELO example.com
250 v238348.srv.net
MAIL FROM: <sender@example.com>
250 OK
RCPT TO: <recipient@example.com>
250 OK
DATA
354 End data with <CR><LF>.<CR><LF>
From: sender@example.com
To: recipient@example.com
Subject: Telnet email

test
.

250 OK
QUIT
221 Bye
Connection closed by foreign host.

actual

220 v238348.srv.net Python SMTP 1.4.4.post2
HELO example.com
250 example.com
MAIL FROM: <sender@example.com>
503 Error: send HELO first

code

    async def handle_HELO(self, server, session, envelope, hostname):
        if hostname != 'example.org':
            return f'250 {hostname}'
        else:
            await server.push('550 5.7.1 Access denied')
            server.transport.close()
            # return '550 5.7.1 Access denied'

    async def handle_EHLO(self, server, session, envelope, hostname, response):
        if hostname != 'example.org':
            return response
        else:
            await server.push('550 5.7.1 Access denied')
            server.transport.close()
            # return [f'550 5.7.1 Access denied']

hint

versions

  • Python 3.9.2
  • 1.4.4.post2

assumption

Seems like extending handle_HELO and handle_EHLO needs more code as expected?

@tobwen
Copy link
Author

tobwen commented Feb 11, 2024

Seems like I missed session.host_name = hostname. Sorry for the noise.

@tobwen tobwen closed this as completed Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant